package com.zy.cq.web.action;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jxl.SheetSettings;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.Number;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.jfree.chart.JFreeChart;

import com.energy.dao.impl.UpdownEletricityConstrueDaoImpl;
import com.opensymphony.xwork2.ActionSupport;
import com.zy.business.commons.support.variable.StaticCheckString;
import com.zy.business.commons.support.variable.StaticVariable;
import com.zy.business.operation.data_select.web.vo.MonitoringObjAllVO;
import com.zy.business.operation.file_manager.web.vo.MonitoringObjEnergyVO;
import com.zy.business.pojo.all.Ammeterinfo;
import com.zy.business.pojo.all.AmmeterinfoId;
import com.zy.business.pojo.all.Dldetail;
import com.zy.cq.common.CommonFunctions;
import com.zy.cq.common.StaticVariables;
import com.zy.cq.common.UpDownDateArea;
import com.zy.cq.common.chart.MyChartClass;
import com.zy.cq.common.chart.ServletSaveImage;
import com.zy.cq.database_service.ammeter.AmmeterServiceInter;
import com.zy.cq.energy_user.construe.EnergyUserConstrueInter;
import com.zy.cq.pojo.MonitoringObj;
import com.zy.cq.util.SharpUtil;
import com.zy.cq.web.vo.ClassConditionerEnergyUserVo;
import com.zy.cq.web.vo.DlstatisticVo;
import com.zy.cq.web.vo.ElecConstrueVo;
import com.zy.cq.web.vo.ElectricConstrueVo;
import com.zy.cq.web.vo.EnergyCraftCompareVo;
import com.zy.cq.web.vo.EnergyTypeElectricityVo;
import com.zy.cq.web.vo.MonitoringObjVo;
import com.zy.cq.web.vo.StatisticAmmeterInfoVo;
import com.zy.cq.web.vo.SynthesizeElecAnlyTabVo;
import com.zy.cq.web.vo.UpAndDownCompareVo;
import com.zy.cq.web.vo.UpAndDownElecTabVo;
import com.zy.cq.web.vo.UpAndDownElecVo;
import com.zy.cq.web.vo.WaterDataVo;

@SuppressWarnings("unchecked")
public class EnergyEletricityConstrueAction extends ActionSupport implements
		ServletRequestAware {

	private static final long serialVersionUID = 1L;
	private AmmeterServiceInter ammeterInfoInter;
	private EnergyUserConstrueInter energyUserConstrueInter;
	private String url;
	private HttpServletRequest request;
	private String startTime; // 开始时间
	private String endTime; // 结束时间
	private String selectType; // 统计类型或分析类型
	private String sameUnitID; // 要做对比分析的同单位ID
	private String userPosition;

	private static String tempFileName = "";// 临时excel文件名称

	// 返回前台的数据：
	private String jsonString;
	// 峰谷
	private List<UpAndDownElecVo> upAndDownElecList;
	private List<UpAndDownElecTabVo> upAndDownElectabList;
	private List<UpAndDownCompareVo> upAndDownCompareList;
	private List<SynthesizeElecAnlyTabVo> synElecPriceList;

	// 能耗折标对比
	private List<EnergyCraftCompareVo> energyCraftCompareVoList = new ArrayList<EnergyCraftCompareVo>();
	// 分"项"能耗分析(和峰谷电量共用VO)
	private List<UpAndDownElecVo> sortElecList;
	// 分"类"能耗分析
	private List<ElecConstrueVo> elecConstrueVoList = new ArrayList<ElecConstrueVo>();

	// 用于分项：
	private Double lightElec;
	private Double airElec;
	private Double driverElec;
	private Double otherElec;

	// 用于分类：
	private Double elec;
	private Double water;
	private Double gas;
	private Double heat;
	private Double col;
	private Double other;

	// 用于峰谷：
	private String monObjName;
	private String date;
	private double sumValue; // 总
	private double upTotalValue; // 峰
	private double middleTotalValue;// 平
	private double downTotalValue; // 谷
	private double upElecPrice = 1.1d;
	private double midElecPrice = 0.8d;
	private double downElecPrice = 0.8d;

	private String upTimeStr;
	private String downTimeStr;
	private String midTimeStr;

	private String monObjName1;
	private String monObjName2;

	// 当前所选对象是否有此功能：(1：节点无此功能；2：第三级节点无主表；3：所选时间段无数据)
	private String objFunction;

	// 用电能耗分析
	public String energyEletricityConstrue() {
		try {
			boolean bPointJsp = false;
			String userNum = request.getParameter("userNum");
			String userName = request.getParameter("userName");
			String userType = request.getParameter("usertype");
			System.out.println("userNum:" + userNum + "\tuserName:" + userName
					+ "\tuserType:" + userType);
			if (userNum != null && !"".equals(userNum)) {
				bPointJsp = true;
				request.getSession().setAttribute(
						StaticVariable.USERNUMSESSION, userNum);
			}
			if (userName != null && !"".equals(userName)) {
				bPointJsp = true;
				request.getSession().setAttribute(
						StaticVariable.USERNAMESESSION, userName);
			}
			if (userType != null && !"".equals(userType)) {
				bPointJsp = true;
				request.getSession().setAttribute(
						StaticVariable.USERTYPESESSION, userType);
			}
			if (bPointJsp)
				return "jsp_page";
			userType = (String) request.getSession().getAttribute(
					StaticVariable.USERTYPESESSION);
			userNum = (String) request.getSession().getAttribute(
					StaticVariable.USERNUMSESSION);
			Long monitorObjId = Long.parseLong(userNum);
			if (this.getStartTime() == null) {
				return SUCCESS;
			}
			MonitoringObj monitorObj = ammeterInfoInter
					.getMonitorObj(monitorObjId);
			String position = "当前能耗分析->用电能耗分析 当前选择： "
					+ monitorObj.getObj_name() + ")";
			this.setUserPosition(position);
			String queryStartTime = "";
			String queryEndTime = "";
			if ("0".equals(selectType) || "8".equals(selectType)) {// 分类分项能耗分析(分项：0；分类：8)
				String timeStr = this.getStartTime().substring(0, 7);
				queryStartTime = this.getStartTime().substring(0, 7)
						+ "-01 00:00:00";
				queryEndTime = SharpUtil.getNextMonth(timeStr) + "-01 00:00:00";
			} else if ("1".equals(selectType)) {// 日单耗
				String timeStr = this.getStartTime().substring(0, 10);
				queryStartTime = timeStr + " 00:00:00";
				queryEndTime = StaticCheckString.getNextDay(timeStr);
			} else if ("2".equals(selectType)) {// 月单耗
				String timeStr = this.getStartTime().substring(0, 10);
				queryStartTime = timeStr + " 00:00:00";
				queryEndTime = SharpUtil.getNextMonth(timeStr);
				queryEndTime = queryEndTime + "-01 00:00:00";
			} else {
				String timeStr = this.getStartTime().substring(0, 7);
				queryStartTime = this.getStartTime().substring(0, 7)
						+ "-01 00:00:00";
				queryEndTime = SharpUtil.getNextMonth(timeStr) + "-01 00:00:00";
			}

			if (StaticCheckString.checkStr(userType)) {
				// 如果值等于空、直接返回出去
				request.setAttribute(" ", StaticVariable.CUEUSER);
				return SUCCESS;
			} else {
				DateFormat dateFormat = new SimpleDateFormat(
						"yyyy-MM-dd HH:mm:ss");
				if ("1".equals(userType)) {
					this.objFunction = "1";
					return SUCCESS;
				} else if ("2".equals(userType)) {
					this.objFunction = "1";
					return SUCCESS;
				} else if ("3".equals(userType) || "4".equals(userType)
						|| "5".equals(userType)) {
					List<Ammeterinfo> reqAmmeterList = ammeterInfoInter
							.getRecursionAmmeterOfMonitoringObj(monitorObjId,
									userType);
					CommonFunctions
							.divideWaterMeterFromAmmeterList(reqAmmeterList);
					// 已经递归地求出了此结点的下统计电量所需的电表
					int startNo = 0;
					int max = 31 * 24 * reqAmmeterList.size();// 一个月最多31天,查整点表码值
					List<Dldetail> detailList = null;
					int selectType = Integer.parseInt(this.getSelectType());
					if (selectType == 0) {// 分项耗电量,存在主表只需查出主表的能耗类别和耗电量，如果主表不存在或能耗类别为空，按所有分支表查询各个
						System.out
								.println("进入第三级结点当前用能情况分析--分类分项能耗统计，第三级结点无总表。");
						List energyTypeList = ammeterInfoInter
								.getAllEnergyTypeObject();
						detailList = ammeterInfoInter.getDLDetail(
								reqAmmeterList, queryStartTime, queryEndTime,
								"2", startNo, max);
						// 下面计算各个电表的耗电量
						List<EnergyTypeElectricityVo> typeVoList = new ArrayList<EnergyTypeElectricityVo>();
						for (Ammeterinfo a : reqAmmeterList) {
							List<StatisticAmmeterInfoVo> voList = getElectricQuantityFromMixList(
									detailList, a);
							Double totalPPValue = 0.0d;
							for (StatisticAmmeterInfoVo v : voList) {
								totalPPValue += Double.parseDouble(v
										.getRea_pp_subtract());
							}
							EnergyTypeElectricityVo typeVo = new EnergyTypeElectricityVo();
							typeVo.setElectircQuantity(totalPPValue + "");
							typeVo.setMeterName(a.getMetername());
							typeVo.setMonitorObjName(a.getMetObjID()
									.getObj_name());
							String energyTypeName = "";
							for (Object obj : energyTypeList) {
								Object objArray[] = (Object[]) obj;
								if (a.getEnergyTypeId().equals(
										Long.parseLong(objArray[0].toString()))) {
									energyTypeName = objArray[1].toString();
									break;
								}
							}
							typeVo.setTypeName(energyTypeName);
							typeVoList.add(typeVo);
						}
						// 下面统计各类型的耗电量
						List<EnergyTypeElectricityVo> reqVoList = new ArrayList<EnergyTypeElectricityVo>();
						for (int i = 0; i < energyTypeList.size(); i++) {
							EnergyTypeElectricityVo v = new EnergyTypeElectricityVo();
							v.setElectircQuantity("0.0");
							Object objArray[] = (Object[]) energyTypeList
									.get(i);
							v.setTypeName(objArray[1].toString());
							reqVoList.add(v);
						}
						for (EnergyTypeElectricityVo v : typeVoList) {
							for (EnergyTypeElectricityVo vv : reqVoList) {
								if (vv.getTypeName().equals(v.getTypeName())) {
									Double totalTypeValue = Double
											.parseDouble(vv
													.getElectircQuantity())
											+ Double.parseDouble(v
													.getElectircQuantity());
									vv.setElectircQuantity(totalTypeValue + "");
									break;
								}
							}
						}
						sortElecList = new ArrayList<UpAndDownElecVo>();
						for (EnergyTypeElectricityVo v : reqVoList) {
							String typeName = v.getTypeName();
							Double elec = v.getElectircQuantity() == null ? 0d
									: Double.parseDouble(v
											.getElectircQuantity());
							if ("照明用电".equals(typeName))
								this.lightElec = elec;
							else if ("空调用电".equals(typeName))
								this.airElec = elec;
							else if ("动力用电".equals(typeName))
								this.driverElec = elec;
							else
								this.otherElec = elec;
							UpAndDownElecVo vo = new UpAndDownElecVo();
							vo.setName(typeName);
							vo.setValue(elec);
							sortElecList.add(vo);
						}
						return SUCCESS;
					}
					// 下面处理非分项能耗统计的情况
					detailList = energyUserConstrueInter.getDLDetail(
							reqAmmeterList, queryStartTime, queryEndTime,
							userType, "1", startNo, max);
					Map<AmmeterinfoId, List<Dldetail>> map = new HashMap<AmmeterinfoId, List<Dldetail>>();
					for (int i = 0; i < reqAmmeterList.size(); i++) {
						Ammeterinfo ammeter = reqAmmeterList.get(i);
						List<Dldetail> tempList = new ArrayList<Dldetail>();
						map.put(ammeter.getId(), tempList);
					}
					Set<AmmeterinfoId> keySet = map.keySet();
					for (Dldetail d : detailList) {
						Long rtuano = d.getTerminalinfo().getRtuano();
						Long ammeterno = d.getAmmeterno();
						for (AmmeterinfoId key : keySet) {
							if (key.getRtuano().equals(rtuano)
									&& key.getAmmeterno().equals(ammeterno)) {
								map.get(key).add(d);
								break;
							}
						}
					}
					Map<AmmeterinfoId, List<ElectricConstrueVo>> reqMap = new HashMap<AmmeterinfoId, List<ElectricConstrueVo>>();
					long oneHourMills = 3600 * 1000;// 1小时的毫秒数
					Calendar endCalendar = Calendar.getInstance();
					Calendar startCalendar = Calendar.getInstance();
					for (AmmeterinfoId key : keySet) {
						List<ElectricConstrueVo> ecvList = new ArrayList<ElectricConstrueVo>();
						List<Dldetail> dlList = map.get(key);
						int size = dlList.size();
						for (int i = 0; i < size - 1; i++) {
							Dldetail d1 = dlList.get(i);
							Dldetail d2 = dlList.get(i + 1);
							Long rtuano = d1.getTerminalinfo().getRtuano();
							Long ammeterno = d1.getAmmeterno();
							long multiRate = getMultiRate(reqAmmeterList,
									rtuano, ammeterno);
							Double dValue1 = d1.getReaPp();
							Double dValue2 = d2.getReaPp();
							if (dValue1 != null && dValue2 != null) {
								Date endTime = d1.getReaDt();
								Date startTime = d2.getReaDt();
								endCalendar.setTime(endTime);
								startCalendar.setTime(startTime);
								if (endCalendar.getTimeInMillis() == startCalendar
										.getTimeInMillis()
										+ oneHourMills) {
									ElectricConstrueVo ecv = new ElectricConstrueVo();
									ecv.setStarttime(d2.getReaDt());
									double reapp = (dValue1 - dValue2)
											* multiRate;
									if (reapp >= 0) {
										ecv.setReapp(reapp);
										ecvList.add(ecv);
									}
								}
							}
						}
						reqMap.put(key, ecvList);
					}
					if (selectType == 1) { // 日单耗
						List<DlstatisticVo> statisticVoList = new ArrayList<DlstatisticVo>();
						Date endTime = dateFormat.parse(queryEndTime.substring(
								0, 13)
								+ ":00:00");
						Date startTime = dateFormat.parse(queryStartTime
								.substring(0, 13)
								+ ":00:00");
						keySet = reqMap.keySet();
						while (endTime.getTime() >= startTime.getTime()) {
							Double tempValue = -1d;
							for (AmmeterinfoId key : keySet) {
								List<ElectricConstrueVo> ecvList = reqMap
										.get(key);
								for (ElectricConstrueVo ecv : ecvList) {
									if (ecv.getStarttime().getTime() == endTime
											.getTime()) {
										tempValue += ecv.getReapp();
									}
								}
							}
							if (tempValue.doubleValue() != -1d) {
								DlstatisticVo dv = new DlstatisticVo();
								dv.setStarttime(dateFormat.format(endTime));
								dv.setPp(tempValue + "");
								statisticVoList.add(dv);
							}
							endTime.setTime(endTime.getTime() - oneHourMills);
						}
						ElecConstrueVo elecVo = null;
						for (DlstatisticVo dlsVo : statisticVoList) {
							elecVo = new ElecConstrueVo();
							elecVo.setDate(dlsVo.getStarttime());
							elecVo.setValue(dlsVo.getPp());
							this.elecConstrueVoList.add(elecVo);
						}

					} else if (selectType == 2) {

					} else if (selectType == 3) {

					} else if (selectType == 4) {

					} else if (selectType == 5) {

					} else if (selectType == 6) {

					} else if (selectType == 7) {

					} else if (selectType == 8) {// 分类能耗分析
						System.out.println("进入第三级结点当前用能情况分析--分类能耗统计，第三级结点无总表。");
						List energyTypeList = ammeterInfoInter
								.getAllEnergyTypeObject();
						detailList = ammeterInfoInter.getDLDetail(
								reqAmmeterList, queryStartTime, queryEndTime,
								"2", startNo, max);
						// 下面计算各个电表的耗电量
						List<EnergyTypeElectricityVo> typeVoList = new ArrayList<EnergyTypeElectricityVo>();
						for (Ammeterinfo a : reqAmmeterList) {
							List<StatisticAmmeterInfoVo> voList = getElectricQuantityFromMixList(
									detailList, a);
							Double totalPPValue = 0.0d;
							for (StatisticAmmeterInfoVo v : voList) {
								totalPPValue += Double.parseDouble(v
										.getRea_pp_subtract());
							}
							EnergyTypeElectricityVo typeVo = new EnergyTypeElectricityVo();
							typeVo.setElectircQuantity(totalPPValue + "");
							typeVo.setMeterName(a.getMetername());
							typeVo.setMonitorObjName(a.getMetObjID()
									.getObj_name());
							String energyTypeName = "";
							for (Object obj : energyTypeList) {
								Object objArray[] = (Object[]) obj;
								if (a.getEnergyTypeId().equals(
										Long.parseLong(objArray[0].toString()))) {
									energyTypeName = objArray[1].toString();
									break;
								}
							}
							typeVo.setTypeName(energyTypeName);
							typeVoList.add(typeVo);
						}
						// 下面统计各类型的耗电量
						List<EnergyTypeElectricityVo> reqVoList = new ArrayList<EnergyTypeElectricityVo>();
						for (int i = 0; i < energyTypeList.size(); i++) {
							EnergyTypeElectricityVo v = new EnergyTypeElectricityVo();
							v.setElectircQuantity("0.0");
							Object objArray[] = (Object[]) energyTypeList
									.get(i);
							v.setTypeName(objArray[1].toString());
							reqVoList.add(v);
						}
						for (EnergyTypeElectricityVo v : typeVoList) {
							for (EnergyTypeElectricityVo vv : reqVoList) {
								if (vv.getTypeName().equals(v.getTypeName())) {
									Double totalTypeValue = Double
											.parseDouble(vv
													.getElectircQuantity())
											+ Double.parseDouble(v
													.getElectircQuantity());
									vv.setElectircQuantity(totalTypeValue + "");
									break;
								}
							}
						}
						Double elec = 0d;
						for (EnergyTypeElectricityVo v : reqVoList) {
							elec += v.getElectircQuantity() == null ? 0d
									: Double.parseDouble(v
											.getElectircQuantity());
						}

						ElecConstrueVo elecConstrueVo = new ElecConstrueVo();
						elecConstrueVo.setEnergyType("耗电量");
						// 电 折标煤
						double elecMarkCoal = elec * 0.1229 / 1000;
						elecConstrueVo.setValue(elecMarkCoal + "");
						this.elec = elecMarkCoal;
						elecConstrueVoList.add(elecConstrueVo);

						MonitoringObjEnergyVO monEnVo = energyUserConstrueInter
								.getMonEnergy(monitorObjId, startTime
										.substring(0, 7));
						elecConstrueVo = new ElecConstrueVo();
						elecConstrueVo.setEnergyType("耗水量");
						this.water = monEnVo.getWaterQuantity() == null ? 0d
								: Double.parseDouble(monEnVo.getWaterQuantity()
										.toString());
						// 水 折标煤
						double waterMarkCoal = this.water * 0.2429 / 1000;
						elecConstrueVo.setValue(waterMarkCoal + "");
						this.water = waterMarkCoal;
						elecConstrueVoList.add(elecConstrueVo);

						elecConstrueVo = new ElecConstrueVo();
						elecConstrueVo.setEnergyType("耗气量");
						this.gas = monEnVo.getNaturalGasQuantity() == null ? 0d
								: Double.parseDouble(monEnVo
										.getNaturalGasQuantity().toString());
						// 气 折标煤
						double gasMarkCoal = this.gas * 1.7143 / 1000;
						elecConstrueVo.setValue(gasMarkCoal + "");
						this.gas = gasMarkCoal;
						elecConstrueVoList.add(elecConstrueVo);

						elecConstrueVo = new ElecConstrueVo();
						elecConstrueVo.setEnergyType("集中供热耗热量");
						this.heat = monEnVo.getHeatPowerQuantity() == null ? 0d
								: Double.parseDouble(monEnVo
										.getHeatPowerQuantity().toString());
						// 热 折标煤
						double heatMarkCoal = this.heat / 1000000 * 1229 / 1000;
						elecConstrueVo.setValue(heatMarkCoal + "");
						this.heat = heatMarkCoal;
						elecConstrueVoList.add(elecConstrueVo);

						elecConstrueVo = new ElecConstrueVo();
						elecConstrueVo.setEnergyType("集中供冷耗冷量");
						// 冷 折标煤(暂没找到公式)
						elecConstrueVo.setValue("0.0"); // --要新增的录入项
						this.col = 0d;
						elecConstrueVoList.add(elecConstrueVo);

						elecConstrueVo = new ElecConstrueVo();
						elecConstrueVo.setEnergyType("其它能源应用量");
						this.other = monEnVo.getOtherEnerQuantity() == null ? 0d
								: Double.parseDouble(monEnVo
										.getOtherEnerQuantity().toString());
						// 其它 折标煤
						double otherMarkCoal = this.other / 7000 / 1000;
						elecConstrueVo.setValue(otherMarkCoal + "");
						this.other = otherMarkCoal;
						elecConstrueVoList.add(elecConstrueVo);
						boolean isValue = false;
						for (ElecConstrueVo vo : elecConstrueVoList) {
							if (!"0.0".equals(vo.getValue())) {
								isValue = true;
								break;
							}
						}
						if (!isValue)
							this.elecConstrueVoList = null;
						return SUCCESS;
					}
					return SUCCESS;
				}
				/*
				 * else if("4".equals(userType)){ Ammeterinfo reqMainAmmeter =
				 * null;//第四级监测对象的主表 for(Ammeterinfo ammeter:ammeterList){ Long
				 * metIsmain = ammeter.getMetIsmain(); if(metIsmain != null &&
				 * metIsmain.equals(1L)){ reqMainAmmeter = ammeter; break; } }
				 * List<String> meterNameList = new ArrayList<String>(); int
				 * ammeterSize = ammeterList.size(); for(int i = 0; i <
				 * ammeterSize; i ++){
				 * meterNameList.add(ammeterList.get(i).getMetername()); } Long
				 * rtuano = null; Long ammeterno = null; if(reqMainAmmeter !=
				 * null){ //存在主表的情况 rtuano = reqMainAmmeter.getId().getRtuano();
				 * ammeterno = reqMainAmmeter.getId().getAmmeterno(); } else{
				 * //不存在主表的情况,暂用列表中的第一个终端 if(ammeterList.size() > 0){
				 * reqMainAmmeter = ammeterList.get(0); rtuano =
				 * reqMainAmmeter.getId().getRtuano(); ammeterno =
				 * reqMainAmmeter.getId().getAmmeterno(); } else{
				 * System.out.println("============没有找到要查询的电表!============");
				 * return StaticVariable.NOREQURIEDDATA; } } //待增加 long
				 * multiRate = reqMainAmmeter.getPt()*reqMainAmmeter.getCt();
				 * if(this.getSelectType() != null){ int selectType =
				 * Integer.parseInt(this.getSelectType()); if(selectType ==
				 * 1){//日单耗 int startNo = 0; int max = 31*24;//一个月最多31天,查整点表码值
				 * List<Dldetail> detailList =
				 * energyUserConstrueInter.getDLDetail( rtuano, ammeterno,
				 * queryStartTime, queryEndTime, userType, "1", startNo, max);
				 * //求出小时耗电量 double totalValue = 0; List<DlstatisticVo>
				 * statisticVoList = new ArrayList<DlstatisticVo>(); int size =
				 * detailList.size(); Calendar endCalendar =
				 * Calendar.getInstance(); Calendar startCalendar =
				 * Calendar.getInstance(); long oneHourMills = 3600*1000;
				 * for(int i = 0; i < size; i ++){ if((i+1) < size){ Dldetail d1
				 * = detailList.get(i); Dldetail d2 = detailList.get(i+1);
				 * Double dValue1 = d1.getReaPp(); Double dValue2 =
				 * d2.getReaPp(); if(dValue1 != null && dValue2 != null){ Date
				 * endTime = d1.getReaDt(); Date startTime = d2.getReaDt();
				 * endCalendar.setTime(endTime);
				 * startCalendar.setTime(startTime);
				 * if(endCalendar.getTimeInMillis() ==
				 * startCalendar.getTimeInMillis()+oneHourMills){ DlstatisticVo
				 * dv = new DlstatisticVo();
				 * dv.setStarttime(dateFormat.format(d2.getReaDt())); double
				 * reapp = (dValue1-dValue2)*multiRate; dv.setPp(reapp + "");
				 * statisticVoList.add(dv); totalValue += reapp; } } } }
				 * ElecConstrueVo elecVo = null; for(DlstatisticVo dlsVo :
				 * statisticVoList){ elecVo = new ElecConstrueVo();
				 * elecVo.setDate(dlsVo.getStarttime());
				 * elecVo.setValue(dlsVo.getPp());
				 * this.elecConstrueVoList.add(elecVo); } }else if(selectType ==
				 * 2){//月度单耗 String tempStartTime =
				 * this.getStartTime().substring(0,7); queryStartTime =
				 * tempStartTime+"-01 00:00:00"; String yearMonth =
				 * SharpUtil.getNextMonth(queryStartTime); queryEndTime =
				 * yearMonth+"-01 00:00:00"; int startNo = 0; int max =
				 * 32;//一个月最多31天,查零点表码值,查到下个月的1号,这样才是这个月真正所耗的电量 List<Dldetail>
				 * detailList = energyUserConstrueInter.getDLDetail( rtuano,
				 * ammeterno, queryStartTime, queryEndTime, userType, "2",
				 * startNo, max); List<DlstatisticVo> statisticVoList = new
				 * ArrayList<DlstatisticVo>(); double totalValue = 0; int size =
				 * detailList.size(); Calendar endCalendar =
				 * Calendar.getInstance(); Calendar startCalendar =
				 * Calendar.getInstance(); long oneDayMills = 24*3600*1000;
				 * for(int i = 0; i < size; i ++){ if((i+1) < size){ Dldetail d1
				 * = detailList.get(i); Dldetail d2 = detailList.get(i+1);
				 * Double dValue1 = d1.getReaPp(); Double dValue2 =
				 * d2.getReaPp(); if(dValue1 != null && dValue2 != null){ Date
				 * endTime = d1.getReaDt(); Date startTime = d2.getReaDt();
				 * endCalendar.setTime(endTime);
				 * startCalendar.setTime(startTime); //
				 * if(endCalendar.get(Calendar.DAY_OF_MONTH) ==
				 * startCalendar.get(Calendar.DAY_OF_MONTH)+1){
				 * //上面的条件不对,在当月的最后一天与下月的第一天之间出现问题
				 * if(endCalendar.getTimeInMillis() ==
				 * startCalendar.getTimeInMillis()+oneDayMills){ DlstatisticVo
				 * dv = new DlstatisticVo();
				 * dv.setStarttime(dateFormat.format(d2.getReaDt())); double
				 * reapp = (dValue1-dValue2)*multiRate; dv.setPp(reapp + "");
				 * statisticVoList.add(dv); totalValue += reapp; } } } }
				 * ElecConstrueVo elecVo = null; for(DlstatisticVo dlsVo :
				 * statisticVoList){ elecVo = new ElecConstrueVo();
				 * elecVo.setDate(dlsVo.getStarttime());
				 * elecVo.setValue(dlsVo.getPp());
				 * this.elecConstrueVoList.add(elecVo); } }else if(selectType ==
				 * 3){//年度单耗 String tempStartTime =
				 * this.getStartTime().substring(0,4); queryStartTime =
				 * tempStartTime+"-01-01 00:00:00"; int year =
				 * Integer.parseInt(tempStartTime)+1; queryEndTime =
				 * year+"-01-01 00:00:00"; int startNo = 0; int max =
				 * 13;//最多12个月 List<Dldetail> detailList =
				 * energyUserConstrueInter.getDLDetail( rtuano, ammeterno,
				 * queryStartTime, queryEndTime, userType, "3", startNo, max);
				 * // System.out.println("detailList:"+detailList.size());
				 * List<DlstatisticVo> statisticVoList = new
				 * ArrayList<DlstatisticVo>(); double totalValue = 0; int size =
				 * detailList.size(); Calendar endCalendar =
				 * Calendar.getInstance(); Calendar startCalendar =
				 * Calendar.getInstance(); long oneDayMills = 24*3600*1000;
				 * SimpleDateFormat df = new SimpleDateFormat("yyyy-MM");
				 * for(int i = 0; i < size; i ++){ if((i+1) < size){ Dldetail d1
				 * = detailList.get(i); Dldetail d2 = detailList.get(i+1);
				 * Double dValue1 = d1.getReaPp(); Double dValue2 =
				 * d2.getReaPp(); if(dValue1 != null && dValue2 != null){ Date
				 * endTime = d1.getReaDt(); Date startTime = d2.getReaDt();
				 * endCalendar.setTime(endTime);
				 * startCalendar.setTime(startTime); String startTimeStr =
				 * df.format(startTime); int daysOfMonth =
				 * SharpUtil.getDayNum(startTimeStr); long oneMonthMills =
				 * daysOfMonth*oneDayMills; if(endCalendar.getTimeInMillis() ==
				 * startCalendar.getTimeInMillis()+oneMonthMills){ DlstatisticVo
				 * dv = new DlstatisticVo();
				 * dv.setStarttime(dateFormat.format(d2.getReaDt())); double
				 * reapp = (dValue1-dValue2)*multiRate; dv.setPp(reapp + "");
				 * statisticVoList.add(dv); totalValue += reapp; } } } }
				 * 
				 * ElecConstrueVo elecVo = null; for(DlstatisticVo dlsVo :
				 * statisticVoList){ elecVo = new ElecConstrueVo();
				 * elecVo.setDate(dlsVo.getStarttime());
				 * elecVo.setValue(dlsVo.getPp());
				 * this.elecConstrueVoList.add(elecVo); } }else if(selectType ==
				 * 4){//日功率因数 List listPowerFactorConstrue =
				 * energyUserConstrueInter.getPowerFactorConstrue(
				 * rtuano,ammeterno,queryStartTime, queryEndTime,userType,"1");
				 * request
				 * .setAttribute("listPowerFactorConstrue",listPowerFactorConstrue
				 * ); request.setAttribute("returnType","2"); } else
				 * if(selectType == 5){//月度功率因数 String tempStartTime =
				 * this.getStartTime().substring(0,7); queryStartTime =
				 * tempStartTime+"-01 00:00:00"; int dayNumOfMonth =
				 * SharpUtil.getDayNum(tempStartTime); queryEndTime =
				 * tempStartTime+"-"+dayNumOfMonth+" 23:59:59"; List
				 * listPowerFactorConstrue =
				 * energyUserConstrueInter.getPowerFactorConstrue(
				 * rtuano,ammeterno,queryStartTime, queryEndTime,userType,"2");
				 * request
				 * .setAttribute("listPowerFactorConstrue",listPowerFactorConstrue
				 * ); request.setAttribute("returnType","2"); } else
				 * if(selectType == 6){//年度功率因数 String tempStartTime =
				 * this.getStartTime().substring(0,4); queryStartTime =
				 * tempStartTime+"-01-01 00:00:00"; tempStartTime =
				 * tempStartTime+"-12"; int dayNumOfMonth =
				 * SharpUtil.getDayNum(tempStartTime); queryEndTime =
				 * tempStartTime+"-"+dayNumOfMonth+" 23:59:59"; List
				 * listPowerFactorConstrue =
				 * energyUserConstrueInter.getPowerFactorConstrue(
				 * rtuano,ammeterno,queryStartTime, queryEndTime,userType,"3");
				 * request
				 * .setAttribute("listPowerFactorConstrue",listPowerFactorConstrue
				 * ); request.setAttribute("returnType","2"); } else
				 * if(selectType == 7){//与内部、行业指标日对比
				 * System.out.println("与内部、行业指标日对比--此功能暂时不用");
				 * request.setAttribute("returnType","3"); } else if(selectType
				 * == 8){//与内部、行业指标月度对比 String tempStartTime =
				 * this.getStartTime().substring(0,7); queryStartTime =
				 * tempStartTime+"-01 00:00:00"; String yearMonth =
				 * SharpUtil.getNextMonth(queryStartTime); queryEndTime =
				 * yearMonth+"-01 00:00:00"; //上面的方法速度较慢
				 * List<DayElectricEnergyStdValue> stdValueList =
				 * energyUserConstrueInter
				 * .getCompareEachDayStdValue(monitorObj,queryStartTime
				 * ,queryEndTime);
				 * 
				 * 
				 * //下面求出当前监测对象的月度能耗 int startNo = 0; int max =
				 * 32;//一个月最多31天,查零点表码值,查到下个月的1号,这样才是这个月真正所耗的电量 List<Dldetail>
				 * detailList = energyUserConstrueInter.getDLDetail( rtuano,
				 * ammeterno, queryStartTime, queryEndTime, userType, "2",
				 * startNo, max); List<DlstatisticVo> statisticVoList = new
				 * ArrayList<DlstatisticVo>(); double totalValue = 0; int size =
				 * detailList.size(); Calendar endCalendar =
				 * Calendar.getInstance(); Calendar startCalendar =
				 * Calendar.getInstance(); long oneDayMills = 24*3600*1000;
				 * for(int i = 0; i < size; i ++){ if((i+1) < size){ Dldetail d1
				 * = detailList.get(i); Dldetail d2 = detailList.get(i+1);
				 * Double dValue1 = d1.getReaPp(); Double dValue2 =
				 * d2.getReaPp(); if(dValue1 != null && dValue2 != null){ Date
				 * endTime = d1.getReaDt(); Date startTime = d2.getReaDt();
				 * endCalendar.setTime(endTime);
				 * startCalendar.setTime(startTime); //
				 * if(endCalendar.get(Calendar.DAY_OF_MONTH) ==
				 * startCalendar.get(Calendar.DAY_OF_MONTH)+1){
				 * //上面的条件不对,在当月的最后一天与下月的第一天之间出现问题
				 * if(endCalendar.getTimeInMillis() ==
				 * startCalendar.getTimeInMillis()+oneDayMills){ DlstatisticVo
				 * dv = new DlstatisticVo();
				 * dv.setStarttime(dateFormat.format(d2.getReaDt())); double
				 * reapp = (dValue1-dValue2)*multiRate; dv.setPp(reapp + "");
				 * statisticVoList.add(dv); totalValue += reapp; } } } }
				 * //将statisticVoList与stdValueList合并 DecimalFormat decimalFormat
				 * = new DecimalFormat(); decimalFormat.setGroupingUsed(false);
				 * decimalFormat.setMaximumFractionDigits(2);
				 * decimalFormat.setMinimumFractionDigits(2);
				 * List<CompareStdValueVo> voList = new
				 * ArrayList<CompareStdValueVo>(); for(DayElectricEnergyStdValue
				 * desv:stdValueList){ String startTimeStr =
				 * dateFormat.format(desv.getDay()); CompareStdValueVo vo = new
				 * CompareStdValueVo(); vo.setStartTime(startTimeStr);
				 * if(desv.getSameMiniTypeStdValue() != null)
				 * vo.setSameMiniTypeStdValue
				 * (decimalFormat.format(desv.getSameMiniTypeStdValue()));
				 * if(desv.getSameCraftStdValue() != null)
				 * vo.setSameCraftStdValue
				 * (decimalFormat.format(desv.getSameCraftStdValue()));
				 * for(DlstatisticVo dv:statisticVoList){
				 * if(startTimeStr.equals(dv.getStarttime())){
				 * vo.setCurMonitorObjValue
				 * (decimalFormat.format(Double.parseDouble(dv.getPp())));
				 * break; } } //对curMonitorObjValue为空的记录以及不正常的记录加以过滤
				 * if(vo.getCurMonitorObjValue() != null &&
				 * !"".equals(vo.getCurMonitorObjValue())){ Double curValue =
				 * Double.parseDouble(vo.getCurMonitorObjValue());
				 * if(vo.getSameMiniTypeStdValue() != null &&
				 * !"".equals(vo.getSameMiniTypeStdValue())){ Double
				 * sameMiniTypeStdValue =
				 * Double.parseDouble(vo.getSameMiniTypeStdValue());
				 * //当同级监测对象平均耗电量是当前监测对象的四倍时，进行过滤 if(sameMiniTypeStdValue/4 >
				 * curValue){ vo.setSameMiniTypeStdValue(""); } }
				 * if(vo.getSameCraftStdValue() != null &&
				 * !"".equals(vo.getSameCraftStdValue())){ Double
				 * sameCraftStdValue =
				 * Double.parseDouble(vo.getSameCraftStdValue());
				 * //当同级监测对象平均耗电量是当前监测对象的四倍时，进行过滤 if(sameCraftStdValue/4 >
				 * curValue){ vo.setSameCraftStdValue(""); } } voList.add(vo); }
				 * } //画出对比曲线 DateFormat df = new
				 * SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); List<ChartPoint>
				 * curChartPointList = new ArrayList<ChartPoint>();//电压A相
				 * List<ChartPoint> sameTypeChartPointList = new
				 * ArrayList<ChartPoint>();//电压B相 List<ChartPoint>
				 * sameCraftChartPointList = new ArrayList<ChartPoint>();//电压C相
				 * for(CompareStdValueVo vo:voList){ Date date =
				 * df.parse(vo.getStartTime()); Day day = new Day(date); Hour
				 * hour = new Hour(date); Minute minute = new Minute(date);
				 * Second second = new Second(date);
				 * 
				 * ChartPoint point1 = new ChartPoint(); point1.setTime(day);
				 * point1.setHour(hour); point1.setMinute(minute);
				 * point1.setSecond(second);
				 * point1.setValue(Double.parseDouble(vo
				 * .getCurMonitorObjValue())); curChartPointList.add(point1);
				 * 
				 * if(vo.getSameMiniTypeStdValue() != null &&
				 * !"".equals(vo.getSameMiniTypeStdValue())){ ChartPoint point2
				 * = new ChartPoint(); point2.setTime(day);
				 * point2.setHour(hour); point2.setMinute(minute);
				 * point2.setSecond(second);
				 * point2.setValue(Double.parseDouble(vo
				 * .getSameMiniTypeStdValue()));
				 * sameTypeChartPointList.add(point2); }
				 * 
				 * if(vo.getSameCraftStdValue() != null &&
				 * !"".equals(vo.getSameCraftStdValue())){ ChartPoint point3 =
				 * new ChartPoint(); point3.setTime(day); point3.setHour(hour);
				 * point3.setMinute(minute); point3.setSecond(second);
				 * point3.setValue
				 * (Double.parseDouble(vo.getSameCraftStdValue()));
				 * sameCraftChartPointList.add(point3); } }
				 * Map<String,List<ChartPoint>> dataMap = new
				 * HashMap<String,List<ChartPoint>>();
				 * dataMap.put("当前对象值",curChartPointList);
				 * dataMap.put("内部标准值",sameTypeChartPointList);
				 * dataMap.put("行业标准值",sameCraftChartPointList); MyChartClass
				 * chartClass = new MyChartClass();
				 * chartClass.setbDisplayPoint(true);
				 * chartClass.setAutoRangeMinimumSize(200d);
				 * chartClass.setTimeType(MyChartClass.TIMETYPE.DAY); JFreeChart
				 * chart =
				 * chartClass.createChart(chartClass.createDataset(dataMap));
				 * ServletSaveImage
				 * .save(chart,1000,450,request,"compareGraphicUrl");
				 * 
				 * request.setAttribute("voList",voList);
				 * request.setAttribute("returnType","3"); } }
				 * ammeterList.clear(); ammeterList.add(reqMainAmmeter);
				 * request.setAttribute("ammeterList", ammeterList); }
				 */
			}
			request.setAttribute("userPosition", this.getUserPosition());
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		return SUCCESS;
	}

	private long getMultiRate(List<Ammeterinfo> ammeterList, long rtuano,
			long ammeterno) {
		for (Ammeterinfo ammeter : ammeterList) {
			long tempRtuano = ammeter.getId().getRtuano();
			long tempAmmeterno = ammeter.getId().getAmmeterno();
			if (tempRtuano == rtuano && tempAmmeterno == ammeterno) {
				return ammeter.getPt() * ammeter.getCt();
			}
		}
		return 0;
	}

	// 班级空调能耗对比
	public String energyUserCraftClassCompare() {
		String usertype = (String) request.getSession().getAttribute(
				StaticVariable.USERTYPESESSION);
		String obj_id = (String) request.getSession().getAttribute(
				StaticVariable.USERNUMSESSION);
		request.setAttribute("position", "当前能耗分析->能耗折标对比");
		String tempStartTime = this.getStartTime().substring(0, 7);
		String queryStartTime = tempStartTime + "-01 00:00:00";
		int dayNumOfMonth = SharpUtil.getDayNum(tempStartTime);
		String queryEndTime = tempStartTime + "-" + dayNumOfMonth + " 23:59:59";

		if (!StaticVariable.checkString(obj_id)) {// 没有选择对象
			return StaticVariable.NOTCHIOCE;
		}
		if ("3".equals(usertype)) {// 单位
			try {
				Long monitorObjId = Long.parseLong(obj_id);
				// MonitoringObj monitorObj =
				// ammeterInfoInter.getMonitorObj(monitorObjId);
				List<Ammeterinfo> ammeterList = ammeterInfoInter
						.getAmmeterByMonitoringObjId(monitorObjId, "3");
				for (Ammeterinfo a : ammeterList) {
					if (a.getId().getAmmeterno().longValue() == 0L) {
						ammeterList.remove(a);
						break;
					}
				}
				Map<Ammeterinfo, List<Dldetail>> detailMap = new TreeMap<Ammeterinfo, List<Dldetail>>();
				Map<Ammeterinfo, Double> reqMap = new TreeMap<Ammeterinfo, Double>();
				Map<Ammeterinfo, Double> lastYearReqMap = new TreeMap<Ammeterinfo, Double>();
				for (Ammeterinfo a : ammeterList) {
					List<Dldetail> tempList = new ArrayList<Dldetail>();
					detailMap.put(a, tempList);
					reqMap.put(a, 0d);
					lastYearReqMap.put(a, 0d);
					// Double radomValue = 1400 + Math.random()*10000%100;
					// lastYearReqMap.put(a, radomValue);
				}
				int start = 0;
				int maxNum = 4 * 24 * 31 * ammeterList.size();// 查询所有的
				List<Dldetail> detailList = energyUserConstrueInter
						.getDLDetail(ammeterList, queryStartTime, queryEndTime,
								"3", "1", start, maxNum);

				Set<Ammeterinfo> keySet = detailMap.keySet();
				for (Dldetail d : detailList) {
					for (Ammeterinfo a : keySet) {
						if (d.getTerminalinfo().getRtuano().equals(
								a.getId().getRtuano())
								&& d.getAmmeterno().equals(
										a.getId().getAmmeterno())) {
							detailMap.get(a).add(d);
							break;
						}
					}
				}
				Double allTotalPP = 0d;
				for (Ammeterinfo a : keySet) {
					List<Dldetail> tempList = detailMap.get(a);
					if (tempList.size() > 1) {
						Long multiRate = a.getPt() * a.getCt();
						Dldetail d1 = tempList.get(0);
						Dldetail d2 = tempList.get(tempList.size() - 1);
						Double totalPP = 0d;
						if (d1.getReaPp() != null && d2.getReaPp() != null) {
							totalPP = (d1.getReaPp() - d2.getReaPp())
									* multiRate;
						}
						allTotalPP += totalPP;
						reqMap.put(a, totalPP);
					}
				}
				Double avgPP = allTotalPP / ammeterList.size();
				// reqMap存放的就是各班空调在指定时间段所耗的电量，算出去年这个时候的耗电量

				// 为演示而添加的数值
				allTotalPP = 0d;
				keySet = reqMap.keySet();
				for (Ammeterinfo a : keySet) {
					if (a.getId().getAmmeterno().longValue() == 1) {
						allTotalPP += reqMap.get(a);
					}
					if (a.getId().getAmmeterno().longValue() == 2) {
						reqMap.put(a, 1529.06d);
						allTotalPP += 1529.06d;
					} else if (a.getId().getAmmeterno().longValue() == 3) {
						reqMap.put(a, 2448.30d);
						allTotalPP += 2448.30d;
					} else if (a.getId().getAmmeterno().longValue() == 4) {
						reqMap.put(a, 2094.40d);
						allTotalPP += 2094.40d;
					} else if (a.getId().getAmmeterno().longValue() == 5) {
						reqMap.put(a, 1531.29d);
						allTotalPP += 1531.29d;
					} else if (a.getId().getAmmeterno().longValue() == 6) {
						reqMap.put(a, 1720.63d);
						allTotalPP += 1720.63d;
					} else if (a.getId().getAmmeterno().longValue() == 7) {
						reqMap.put(a, 1530.61d);
						allTotalPP += 1530.61d;
					}
				}
				avgPP = allTotalPP / ammeterList.size();

				// 下面画出柱状图
				Map<Ammeterinfo, Double> kVMap = new TreeMap<Ammeterinfo, Double>();
				keySet = reqMap.keySet();
				for (Ammeterinfo a : keySet) {
					kVMap.put(a, reqMap.get(a));
				}
				Ammeterinfo ammeter = new Ammeterinfo();
				ammeter.setMetername("平均值");
				AmmeterinfoId id = new AmmeterinfoId();
				id.setAmmeterno(0L);
				ammeter.setId(id);
				kVMap.put(ammeter, avgPP);

				MyChartClass charClass = new MyChartClass();
				JFreeChart chart = charClass.createSimpleBarChart(charClass
						.createBarGraphicDataset(kVMap, "班级空调用电情况(单位:kWh)"));
				ServletSaveImage.save(chart, 1000, 500, request);

				Map<Ammeterinfo, ClassConditionerEnergyUserVo> voMap = new TreeMap<Ammeterinfo, ClassConditionerEnergyUserVo>();
				for (Ammeterinfo a : keySet) {
					ClassConditionerEnergyUserVo vo = new ClassConditionerEnergyUserVo();
					vo.setReappValue(reqMap.get(a) + "");
					vo
							.setLastYearSameTimeReappValue(lastYearReqMap
									.get(a)
									+ "");
					voMap.put(a, vo);
				}
				request.setAttribute("voMap", voMap);
				request.setAttribute("educateEnergyUser", "1");
				request.setAttribute("returnType", "2");
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else if ("4".equals(usertype) || "5".equals(usertype)) {
			return StaticVariable.CHILDNOTFUNCTION;
		} else {
			return StaticVariable.NOTFUNCTION;
		}
		return SUCCESS;
	}

	// 能耗折标对比
	public String energyCraftCompare() {
		boolean bPointJsp = false;
		String userNum = request.getParameter("userNum");
		String userName = request.getParameter("userName");
		String userType = request.getParameter("usertype");
		System.out.println("userNum:" + userNum + "\tuserName:" + userName
				+ "\tuserType:" + userType);
		if (userNum != null && !"".equals(userNum)) {
			bPointJsp = true;
			request.getSession().setAttribute(StaticVariable.USERNUMSESSION,
					userNum);
		}
		if (userName != null && !"".equals(userName)) {
			bPointJsp = true;
			request.getSession().setAttribute(StaticVariable.USERNAMESESSION,
					userName);
		}
		if (userType != null && !"".equals(userType)) {
			bPointJsp = true;
			request.getSession().setAttribute(StaticVariable.USERTYPESESSION,
					userType);
		}
		if (bPointJsp)
			return "jsp_page";
		userType = (String) request.getSession().getAttribute(
				StaticVariable.USERTYPESESSION);
		userNum = (String) request.getSession().getAttribute(
				StaticVariable.USERNUMSESSION);

		request.setAttribute("position", "当前能耗分析->能耗折标对比");
		if (!StaticVariable.checkString(userNum)) {// 没有选择对象
			return SUCCESS;
		}
		if ("3".equals(userType) || "4".equals(userType)
				|| "5".equals(userType)) { // 单位
			try {
				Long monitorObjId = Long.parseLong(userNum);
				MonitoringObj monitorObj = ammeterInfoInter
						.getMonitorObj(monitorObjId);
				if (monitorObj.getObj_industry_sector().intValue() == 3) {// 文化教育
					request.setAttribute("educateEnergyUser", "1");
				}
				// 查询此结点在树中所有同级结点，以前是request.setAttribute("sameUnitList",
				// energyUserConstrueInter.getSameUnitList(obj_id));//同单位可供对比的对象列表
				List<MonitoringObjVo> sameUnitList = new ArrayList<MonitoringObjVo>();
				List<MonitoringObjVo> levelNodeList = StaticVariable
						.getSpecialLevelTreeNodes(Integer.parseInt(userType));
				for (MonitoringObjVo v : levelNodeList) {
					if (v.getObj_id().equals(userNum))
						continue;
					sameUnitList.add(v);
				}
				request.setAttribute("sameUnitList", sameUnitList);
				if (this.startTime != null) {
					if (this.startTime.length() > 7)
						this.setStartTime(this.startTime.substring(0, 7));
					request.setAttribute("startTime", this.startTime);
					List<Ammeterinfo> reqAmmeterList = ammeterInfoInter
							.getRecursionAmmeterOfMonitoringObj(monitorObjId,
									userType);
					CommonFunctions
							.divideWaterMeterFromAmmeterList(reqAmmeterList);
					List monitorAllList = energyUserConstrueInter
							.getMonitorAllList(userNum, reqAmmeterList,
									this.startTime, selectType);

					// 如果没有值，则直接返回
					boolean isValue = false;
					for (int i = 0; i < monitorAllList.size(); i++) {
						MonitoringObjAllVO monVo = (MonitoringObjAllVO) monitorAllList
								.get(i);
						if (!"0.0".equals(monVo.getMarkCoal().toString())) {
							isValue = true;
						}
					}
					if (!isValue) {
						return SUCCESS;
					}
					// 同级对象对比
					if (this.sameUnitID != null && !"".equals(sameUnitID)) {
						if (monitorAllList.size() > 0) {
							// 当前
							MonitoringObjAllVO monVo = (MonitoringObjAllVO) monitorAllList
									.get(0);
							setEcValue("自身当前", monVo);
							monitorAllList.remove(0);

							monVo = (MonitoringObjAllVO) energyUserConstrueInter
									.getSameUnitVO(sameUnitID, userType,
											this.startTime, selectType);
							setEcValue("同级对象", monVo);

							monVo = (MonitoringObjAllVO) monitorAllList.get(0);
							setEcValue("去年同期 ", monVo);
							monitorAllList.remove(0);

							for (int i = 0; i < monitorAllList.size(); i++) {
								monVo = (MonitoringObjAllVO) monitorAllList
										.get(i);
								setEcValue("历史月份" + (i + 1), monVo);
							}
							return SUCCESS;
						}
						return StaticVariable.NOREQURIEDDATA;
					} else {
						if (monitorAllList.size() > 0) {
							// 当前
							MonitoringObjAllVO monVo = (MonitoringObjAllVO) monitorAllList
									.get(0);
							setEcValue("自身当前 ", monVo);
							monitorAllList.remove(0);
							monVo = (MonitoringObjAllVO) monitorAllList.get(0);
							setEcValue("去年同期 ", monVo);
							monitorAllList.remove(0);

							for (int i = 0; i < monitorAllList.size(); i++) {
								monVo = (MonitoringObjAllVO) monitorAllList
										.get(i);
								setEcValue("历史月份" + (i + 1), monVo);
							}
							return SUCCESS;
						}
						return StaticVariable.NOREQURIEDDATA;
					}
				}
			} catch (Exception ex) {
				ex.printStackTrace();
				return StaticVariable.SERVERERROR;
			}
			return SUCCESS;
		} else {
			this.objFunction = "1";
			return SUCCESS;
		}
	}

	/*
	 * 为能耗折标对比设值用的
	 */
	public void setEcValue(String dateName, MonitoringObjAllVO monVo) {
		EnergyCraftCompareVo ecVo = new EnergyCraftCompareVo();
		ecVo.setDateName(dateName + "(" + monVo.getDt() + ")"); // 日期名称
		// ecVo.setDate(monVo.getDt()); //日期
		ecVo.setObj_Name(monVo.getObj_Name()); // 单位名称
		ecVo.setObj_Area(monVo.getObj_Area()); // 面积
		ecVo.setObj_population(monVo.getObj_population());// 人口
		ecVo.setSumMarkCoal(monVo.getMarkCoal()); // 汇总标煤
		ecVo.setAreaMarkCoal(monVo.getAreaElec()); // 单位面积能耗
		ecVo.setPeopleMarkCoal(monVo.getPeopleElea()); // 人均能耗
		ecVo.setCo2(monVo.getCarbonQuantity()); // 碳排量
		this.energyCraftCompareVoList.add(ecVo);
	};

	/**
	 * 峰谷电量分析
	 */
	public String updownEletricityConstrue() {
		try {

			boolean bPointJsp = false;
			String userNum = request.getParameter("userNum");
			String userName = request.getParameter("userName");
			String userType = request.getParameter("usertype");
			System.out.println("userNum:" + userNum + "\tuserName:" + userName
					+ "\tuserType:" + userType);

			if (userNum != null && !"".equals(userNum)) {
				bPointJsp = true;
				request.getSession().setAttribute(
						StaticVariable.USERNUMSESSION, userNum);
			}
			if (userName != null && !"".equals(userName)) {
				bPointJsp = true;
				request.getSession().setAttribute(
						StaticVariable.USERNAMESESSION, userName);
			}
			if (userType != null && !"".equals(userType)) {
				bPointJsp = true;
				request.getSession().setAttribute(
						StaticVariable.USERTYPESESSION, userType);
			}
			if (bPointJsp)
				return "jsp_page";
			userType = (String) request.getSession().getAttribute(
					StaticVariable.USERTYPESESSION);
			userNum = (String) request.getSession().getAttribute(
					StaticVariable.USERNUMSESSION);
			if (this.getStartTime() == null) {
				return SUCCESS;
			}
			Long monitorObjId = Long.parseLong(userNum);
			MonitoringObj monitorObj = null;

			if (StaticCheckString.checkStr(userType)) {// 如果值等于空、直接返回出去
				request.setAttribute("returnValue", StaticVariable.CUEUSER);
				return SUCCESS;
			} else {
				String queryStartTime = "";
				String queryEndTime = "";
				String timeStr = this.getStartTime().substring(0, 7)
						+ "-01 00:00:00";
				if ("1".equals(userType) || "2".equals(userType)) {
					this.objFunction = "1";
					return SUCCESS;
				} else if ("3".equals(userType) || "4".equals(userType)
						|| "5".equals(userType)) {
					if (timeStr == null || "".equals(timeStr)
							|| "null".equals(timeStr)) {// 进入查询条件选择界面
						return SUCCESS;
					}

					URL url = UpdownEletricityConstrueDaoImpl.class
							.getProtectionDomain().getCodeSource()
							.getLocation();

					String filePath = url.getPath();
					// System.out.println("[Debug] url = " + url);
					// System.out.println("[Debug] filePath = " + filePath);
					filePath = filePath.substring(0,
							filePath.lastIndexOf("/") + 1);
					filePath = filePath.substring(0, filePath
							.indexOf("WEB-INF"));
					filePath = filePath
							+ "WEB-INF/classes/upAndDownTime.properties";
					File file = new File(filePath);
					FileInputStream fis = new FileInputStream(file);
					// Map接口的子类Properties,键值对对象
					Properties props = new Properties();
					// fis中的键值对信息装载到props对象中
					props.load(fis);
					// 从键值对对象props中通过key找到value
					upTimeStr = props.getProperty("upTime");
					downTimeStr = props.getProperty("downTime");
					midTimeStr = props.getProperty("middleTime");
					monitorObj = ammeterInfoInter.getMonitorObj(monitorObjId);

					if ("1".equals(this.getSelectType())) {// 月度统计
						queryStartTime = timeStr;
						queryEndTime = SharpUtil.getNextMonth(timeStr)
								+ "-01 00:00:00";
					} else if ("2".equals(this.getSelectType())) {// 年度统计
						timeStr = timeStr.substring(0, 4);
						queryStartTime = timeStr + "-01-01 00:00:00";
						int year = Integer.parseInt(timeStr) + 1;
						queryEndTime = year + "-01-01 00:00:00";
					}

					// System.out.println("[Debug queryEndtime = " +
					// queryEndTime);
					// System.out.println("[Debug querystartime = " +
					// queryStartTime);

					List<Ammeterinfo> reqAmmeterList = ammeterInfoInter
							.getRecursionAmmeterOfMonitoringObj(monitorObjId,
									userType);
					CommonFunctions
							.divideWaterMeterFromAmmeterList(reqAmmeterList);
					List list = energyUserConstrueInter.getEnergyStatistic(
							reqAmmeterList, queryStartTime, queryEndTime); // ???
					DateFormat dateFormat = new SimpleDateFormat(
							"yyyy-MM-dd HH:mm:ss");
					DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH");
					DateFormat df_ = new SimpleDateFormat("yyyy-MM-dd");
					List<DlstatisticVo> statisticVoList = new ArrayList<DlstatisticVo>(); // /???
					Calendar endCalendar = Calendar.getInstance();
					Calendar startCalendar = Calendar.getInstance();

					// System.out.println("[Debug] list.size = " + list.size());
					// //418

					if (list.size() <= 0) { // 如果一条记录也没查到，应直接返回，下面都不必执行
						return SUCCESS;
					}
					// 得到峰谷电价
					Double priceArray[] = energyUserConstrueInter
							.getDifferentElecPrice();
					upElecPrice = priceArray[0];
					midElecPrice = priceArray[1];
					downElecPrice = priceArray[2];
					System.out.println("upElecPrice:" + upElecPrice
							+ "\tmidElecPrice:" + midElecPrice
							+ "\tdownElecPrice:" + downElecPrice);

					// 初始化操作 upAndDownElectabList
					upAndDownElectabList = new ArrayList<UpAndDownElecTabVo>();
					if ("1".equals(this.getSelectType())) { // 月查询
						UpAndDownElecTabVo tabVo = new UpAndDownElecTabVo();
						tabVo.setDate(queryStartTime.substring(0, 10));
						tabVo.setMonObjName(monitorObj.getObj_name());
						tabVo.setSumValue(-1d);
						tabVo.setUpTotalValue(-1d);
						tabVo.setDownTotalValue(-1d);
						tabVo.setMiddleTotalValue(-1d);
						upAndDownElectabList.add(tabVo);

						long milliSecond = 24 * 60 * 60 * 1000;
						int dotCount = StaticCheckString
								.getMaxDayOfMonth(queryStartTime);
						for (int i = 1; i < dotCount; i++) {
							long tempMilliSecond = df_.parse(tabVo.getDate())
									.getTime()
									+ milliSecond;
							tabVo = new UpAndDownElecTabVo();
							tabVo.setDate(df_.format(tempMilliSecond));
							tabVo.setMonObjName(monitorObj.getObj_name());
							tabVo.setSumValue(-1d);
							tabVo.setUpTotalValue(-1d);
							tabVo.setDownTotalValue(-1d);
							tabVo.setMiddleTotalValue(-1d);
							upAndDownElectabList.add(tabVo);
						}
					} else { // 年查询
						String month = "";
						UpAndDownElecTabVo tabVo = null;
						for (int i = 1; i <= 12; i++) {
							tabVo = new UpAndDownElecTabVo();
							if (i < 10)
								month = "0" + i;
							else
								month = String.valueOf(i);
							tabVo.setDate(queryStartTime.substring(0, 4) + "-"
									+ month);
							tabVo.setMonObjName(monitorObj.getObj_name());
							tabVo.setSumValue(-1d);
							tabVo.setUpTotalValue(-1d);
							tabVo.setDownTotalValue(-1d);
							tabVo.setMiddleTotalValue(-1d);
							upAndDownElectabList.add(tabVo);
						}
					}

					double totalValue = 0; // ????
					for (int i = 0; i < list.size(); i++) {
						Object[] obj = (Object[]) list.get(i);
						if (obj[1] != null) {
							double reapp = Double
									.parseDouble(obj[1].toString());

							if (reapp > 0.00d) {
								DlstatisticVo dv = new DlstatisticVo();
								dv.setStarttime(dateFormat.format(df
										.parse(obj[0].toString())));
								dv.setPp(reapp + "");
								statisticVoList.add(dv);
								totalValue += reapp;
							}
						}
					}

					// 峰、平、谷
					Map<Integer, List<UpDownDateArea>> timeAreaMap = energyUserConstrueInter
							.getElectricUpDownDateArea();
					Set<Integer> keySet = timeAreaMap.keySet();
					Calendar voStartCalendar = Calendar.getInstance();

					// ------------------------------
					// 每天的电量(解决)
					int end = 7; // 年
					if ("1".equals(this.getSelectType())) {
						end = 10; // 月
					}
					for (UpAndDownElecTabVo tabVo : upAndDownElectabList) {
						double dayTotalValue = 0;
						for (int i = 0; i < list.size(); i++) {
							Object[] obj = (Object[]) list.get(i);
							if (obj[1] != null) {
								double reapp = Double.parseDouble(obj[1]
										.toString());
								String date2 = dateFormat.format(
										df.parse(obj[0].toString())).substring(
										0, end);
								if (tabVo.getDate().equals(date2))
									dayTotalValue += reapp;
							}

						}
						if (dayTotalValue != 0.0)
							tabVo.setSumValue(dayTotalValue);
					}
					for (UpAndDownElecTabVo tabVo : upAndDownElectabList) {
						double dayUpTotalValue = 0; // 每天的峰期耗电量
						double dayDownTotalValue = 0; // 每天的谷期耗电量
						double dayMiddleTotalValue = 0; // 每天 的平期耗电量
						for (DlstatisticVo vo : statisticVoList) {
							String date2 = dateFormat.format(
									df.parse(vo.getStarttime())).substring(0,
									end);
							if (tabVo.getDate().equals(date2)) {
								String voStartTimeStr = vo.getStarttime();
								Date voStartTime = dateFormat
										.parse(voStartTimeStr);
								voStartCalendar.setTime(voStartTime);
								int voHourOfDay = voStartCalendar
										.get(Calendar.HOUR_OF_DAY);
								for (Integer key : keySet) {
									if (key.intValue() == StaticVariables.ELECTRICDATEAREA_UP) {
										// 峰期耗电量
										List<UpDownDateArea> upTimeArea = timeAreaMap
												.get(key);
										for (int i = 0; i < upTimeArea.size(); i++) {
											UpDownDateArea upTime = upTimeArea
													.get(i);
											Date startDate = upTime
													.getStartTime();
											Date endDate = upTime.getEndTime();
											startCalendar.setTime(startDate);
											int startHour = startCalendar
													.get(Calendar.HOUR_OF_DAY);
											endCalendar.setTime(endDate);
											int endHour = endCalendar
													.get(Calendar.HOUR_OF_DAY);
											if (voHourOfDay >= startHour
													&& voHourOfDay <= endHour) {
												dayUpTotalValue += Double
														.parseDouble(vo.getPp());
												break;
											}
										}
									} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_DOWN) {
										// 谷期耗电量
										List<UpDownDateArea> downTimeArea = timeAreaMap
												.get(key);
										for (int i = 0; i < downTimeArea.size(); i++) {
											UpDownDateArea downTime = downTimeArea
													.get(i);
											Date startDate = downTime
													.getStartTime();
											Date endDate = downTime
													.getEndTime();
											startCalendar.setTime(startDate);
											int startHour = startCalendar
													.get(Calendar.HOUR_OF_DAY);
											endCalendar.setTime(endDate);
											int endHour = endCalendar
													.get(Calendar.HOUR_OF_DAY);
											if (voHourOfDay >= startHour
													&& voHourOfDay <= endHour) {
												dayDownTotalValue += Double
														.parseDouble(vo.getPp());
												break;
											}
										}
									} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_MIDDLE) {
										// 平期耗电量
										List<UpDownDateArea> midTimeArea = timeAreaMap
												.get(key);
										for (int i = 0; i < midTimeArea.size(); i++) {
											UpDownDateArea midTime = midTimeArea
													.get(i);
											Date startDate = midTime
													.getStartTime();
											Date endDate = midTime.getEndTime();
											startCalendar.setTime(startDate);
											int startHour = startCalendar
													.get(Calendar.HOUR_OF_DAY);
											endCalendar.setTime(endDate);
											int endHour = endCalendar
													.get(Calendar.HOUR_OF_DAY);
											if (voHourOfDay >= startHour
													&& voHourOfDay <= endHour) {
												dayMiddleTotalValue += Double
														.parseDouble(vo.getPp());
												break;
											}
										}
									}
								}
							}
						}
						if (dayUpTotalValue != 0.0)
							tabVo.setUpTotalValue(dayUpTotalValue);
						if (dayDownTotalValue != 0.0)
							tabVo.setDownTotalValue(dayDownTotalValue);
						if (dayMiddleTotalValue != 0.0)
							tabVo.setMiddleTotalValue(dayMiddleTotalValue);
					}

					double upTotalValue = 0;
					double downTotalValue = 0;
					double middleTotalValue = 0;
					for (DlstatisticVo vo : statisticVoList) {
						String voStartTimeStr = vo.getStarttime();
						Date voStartTime = dateFormat.parse(voStartTimeStr);
						voStartCalendar.setTime(voStartTime);
						int voHourOfDay = voStartCalendar
								.get(Calendar.HOUR_OF_DAY);
						if (selectType.equals("1") // 月份的情况；
								&& voStartTime.getMonth() == (dateFormat
										.parse(timeStr).getMonth())) {
							for (Integer key : keySet) {
								if (key.intValue() == StaticVariables.ELECTRICDATEAREA_UP) {
									// 峰期耗电量
									List<UpDownDateArea> upTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < upTimeArea.size(); i++) {
										UpDownDateArea upTime = upTimeArea
												.get(i);
										Date startDate = upTime.getStartTime();
										Date endDate = upTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											upTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_DOWN) {
									// 谷期耗电量
									List<UpDownDateArea> downTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < downTimeArea.size(); i++) {
										UpDownDateArea downTime = downTimeArea
												.get(i);
										Date startDate = downTime
												.getStartTime();
										Date endDate = downTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											downTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_MIDDLE) {
									// 平期耗电量
									List<UpDownDateArea> midTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < midTimeArea.size(); i++) {
										UpDownDateArea midTime = midTimeArea
												.get(i);
										Date startDate = midTime.getStartTime();
										Date endDate = midTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											middleTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								}
							}

						} else if (selectType.equals("2")) { // 年份的情况；
							for (Integer key : keySet) {
								if (key.intValue() == StaticVariables.ELECTRICDATEAREA_UP) {
									// 峰期耗电量
									List<UpDownDateArea> upTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < upTimeArea.size(); i++) {
										UpDownDateArea upTime = upTimeArea
												.get(i);
										Date startDate = upTime.getStartTime();
										Date endDate = upTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											upTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_DOWN) {
									// 谷期耗电量
									List<UpDownDateArea> downTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < downTimeArea.size(); i++) {
										UpDownDateArea downTime = downTimeArea
												.get(i);
										Date startDate = downTime
												.getStartTime();
										Date endDate = downTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											downTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_MIDDLE) {
									// 平期耗电量
									List<UpDownDateArea> midTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < midTimeArea.size(); i++) {
										UpDownDateArea midTime = midTimeArea
												.get(i);
										Date startDate = midTime.getStartTime();
										Date endDate = midTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											middleTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								}
							}
						}
					}

					System.out.println("[Debug] sameUnitID = " + sameUnitID);
					// 同级对象峰期电量对比
					if (sameUnitID != null) {
						upAndDownCompareList = new ArrayList<UpAndDownCompareVo>();
						UpAndDownCompareVo compareVo = new UpAndDownCompareVo();
						for (UpAndDownElecTabVo v : upAndDownElectabList) {
							compareVo = new UpAndDownCompareVo();
							compareVo.setDate(v.getDate());
							compareVo.setValue1(v.getUpTotalValue());
							upAndDownCompareList.add(compareVo);
						}
						this.monObjName1 = monitorObj.getObj_name();
						monitorObj = ammeterInfoInter.getMonitorObj(Long
								.parseLong(sameUnitID));
						this.monObjName2 = monitorObj.getObj_name();

						reqAmmeterList = ammeterInfoInter
								.getRecursionAmmeterOfMonitoringObj(Long
										.parseLong(sameUnitID), userType);
						CommonFunctions
								.divideWaterMeterFromAmmeterList(reqAmmeterList);
						list = energyUserConstrueInter.getEnergyStatistic(
								reqAmmeterList, queryStartTime, queryEndTime);
						statisticVoList = new ArrayList<DlstatisticVo>();

						if (list.size() <= 0) { // 如果一条记录也没查到，应直接返回，下面都不必执行
							return SUCCESS;
						}
						upAndDownElectabList = new ArrayList<UpAndDownElecTabVo>();
						if ("1".equals(this.getSelectType())) { // 月查询
							UpAndDownElecTabVo tabVo = new UpAndDownElecTabVo();
							tabVo.setDate(queryStartTime.substring(0, 10));
							tabVo.setMonObjName(monitorObj.getObj_name());
							tabVo.setSumValue(-1d);
							tabVo.setUpTotalValue(-1d);
							tabVo.setDownTotalValue(-1d);
							tabVo.setMiddleTotalValue(-1d);
							upAndDownElectabList.add(tabVo);

							long milliSecond = 24 * 60 * 60 * 1000;
							int dotCount = StaticCheckString
									.getMaxDayOfMonth(queryStartTime);
							for (int i = 1; i < dotCount; i++) {
								long tempMilliSecond = df_.parse(
										tabVo.getDate()).getTime()
										+ milliSecond;
								tabVo = new UpAndDownElecTabVo();
								tabVo.setDate(df_.format(tempMilliSecond));
								tabVo.setMonObjName(monitorObj.getObj_name());
								tabVo.setSumValue(-1d);
								tabVo.setUpTotalValue(-1d);
								tabVo.setDownTotalValue(-1d);
								tabVo.setMiddleTotalValue(-1d);
								upAndDownElectabList.add(tabVo);
							}
						} else {
							String month = "";
							UpAndDownElecTabVo tabVo = null;
							for (int i = 1; i <= 12; i++) {
								tabVo = new UpAndDownElecTabVo();
								if (i < 10)
									month = "0" + i;
								else
									month = String.valueOf(i);
								tabVo.setDate(queryStartTime.substring(0, 4)
										+ "-" + month);
								tabVo.setMonObjName(monitorObj.getObj_name());
								tabVo.setSumValue(-1d);
								tabVo.setUpTotalValue(-1d);
								tabVo.setDownTotalValue(-1d);
								tabVo.setMiddleTotalValue(-1d);
								upAndDownElectabList.add(tabVo);
							}
						}

						totalValue = 0;
						for (int i = 0; i < list.size(); i++) {
							Object[] obj = (Object[]) list.get(i);
							if (obj[1] != null) {
								double reapp = Double.parseDouble(obj[1]
										.toString());
								if (reapp > 0.00d) {
									DlstatisticVo dv = new DlstatisticVo();
									dv.setStarttime(dateFormat.format(df
											.parse(obj[0].toString())));
									dv.setPp(reapp + "");
									statisticVoList.add(dv);
									totalValue += reapp;
								}
							}
						}

						// 峰、平、谷
						timeAreaMap = energyUserConstrueInter
								.getElectricUpDownDateArea();
						keySet = timeAreaMap.keySet();
						voStartCalendar = Calendar.getInstance();

						// 每天的电量(解决)
						end = 7; // 年
						if ("1".equals(this.getSelectType())) {
							end = 10; // 月
						}
						for (UpAndDownElecTabVo tabVo : upAndDownElectabList) {
							double dayTotalValue = 0;
							for (int i = 0; i < list.size(); i++) {
								Object[] obj = (Object[]) list.get(i);
								double reapp = Double.parseDouble(obj[1]
										.toString());
								String date2 = dateFormat.format(
										df.parse(obj[0].toString())).substring(
										0, end);
								if (tabVo.getDate().equals(date2))
									dayTotalValue += reapp;

							}
							if (dayTotalValue != 0.0)
								tabVo.setSumValue(dayTotalValue);
						}
						for (UpAndDownElecTabVo tabVo : upAndDownElectabList) {
							double dayUpTotalValue = 0;
							double dayDownTotalValue = 0;
							double dayMiddleTotalValue = 0;
							for (DlstatisticVo vo : statisticVoList) {
								String date2 = dateFormat.format(
										df.parse(vo.getStarttime())).substring(
										0, end);
								if (tabVo.getDate().equals(date2)) {
									String voStartTimeStr = vo.getStarttime();
									Date voStartTime = dateFormat
											.parse(voStartTimeStr);
									voStartCalendar.setTime(voStartTime);
									int voHourOfDay = voStartCalendar
											.get(Calendar.HOUR_OF_DAY);
									for (Integer key : keySet) {
										if (key.intValue() == StaticVariables.ELECTRICDATEAREA_UP) {
											// 峰期耗电量
											List<UpDownDateArea> upTimeArea = timeAreaMap
													.get(key);
											for (int i = 0; i < upTimeArea
													.size(); i++) {
												UpDownDateArea upTime = upTimeArea
														.get(i);
												Date startDate = upTime
														.getStartTime();
												Date endDate = upTime
														.getEndTime();
												startCalendar
														.setTime(startDate);
												int startHour = startCalendar
														.get(Calendar.HOUR_OF_DAY);
												endCalendar.setTime(endDate);
												int endHour = endCalendar
														.get(Calendar.HOUR_OF_DAY);
												if (voHourOfDay >= startHour
														&& voHourOfDay <= endHour) {
													dayUpTotalValue += Double
															.parseDouble(vo
																	.getPp());
													break;
												}
											}
										} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_DOWN) {
											// 谷期耗电量
											List<UpDownDateArea> downTimeArea = timeAreaMap
													.get(key);
											for (int i = 0; i < downTimeArea
													.size(); i++) {
												UpDownDateArea downTime = downTimeArea
														.get(i);
												Date startDate = downTime
														.getStartTime();
												Date endDate = downTime
														.getEndTime();
												startCalendar
														.setTime(startDate);
												int startHour = startCalendar
														.get(Calendar.HOUR_OF_DAY);
												endCalendar.setTime(endDate);
												int endHour = endCalendar
														.get(Calendar.HOUR_OF_DAY);
												if (voHourOfDay >= startHour
														&& voHourOfDay <= endHour) {
													dayDownTotalValue += Double
															.parseDouble(vo
																	.getPp());
													break;
												}
											}
										} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_MIDDLE) {
											// 平期耗电量
											List<UpDownDateArea> midTimeArea = timeAreaMap
													.get(key);
											for (int i = 0; i < midTimeArea
													.size(); i++) {
												UpDownDateArea midTime = midTimeArea
														.get(i);
												Date startDate = midTime
														.getStartTime();
												Date endDate = midTime
														.getEndTime();
												startCalendar
														.setTime(startDate);
												int startHour = startCalendar
														.get(Calendar.HOUR_OF_DAY);
												endCalendar.setTime(endDate);
												int endHour = endCalendar
														.get(Calendar.HOUR_OF_DAY);
												if (voHourOfDay >= startHour
														&& voHourOfDay <= endHour) {
													dayMiddleTotalValue += Double
															.parseDouble(vo
																	.getPp());
													break;
												}
											}
										}
									}
								}
							}
							if (dayUpTotalValue != 0.0)
								tabVo.setUpTotalValue(dayUpTotalValue);
							if (dayDownTotalValue != 0.0)
								tabVo.setDownTotalValue(dayDownTotalValue);
							if (dayMiddleTotalValue != 0.0)
								tabVo.setMiddleTotalValue(dayMiddleTotalValue);
						}
						upTotalValue = 0;
						downTotalValue = 0;
						middleTotalValue = 0;
						for (DlstatisticVo vo : statisticVoList) {
							String voStartTimeStr = vo.getStarttime();
							Date voStartTime = dateFormat.parse(voStartTimeStr);
							voStartCalendar.setTime(voStartTime);
							int voHourOfDay = voStartCalendar
									.get(Calendar.HOUR_OF_DAY);
							for (Integer key : keySet) {
								if (key.intValue() == StaticVariables.ELECTRICDATEAREA_UP) {
									// 峰期耗电量
									List<UpDownDateArea> upTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < upTimeArea.size(); i++) {
										UpDownDateArea upTime = upTimeArea
												.get(i);
										Date startDate = upTime.getStartTime();
										Date endDate = upTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											upTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_DOWN) {
									// 谷期耗电量
									List<UpDownDateArea> downTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < downTimeArea.size(); i++) {
										UpDownDateArea downTime = downTimeArea
												.get(i);
										Date startDate = downTime
												.getStartTime();
										Date endDate = downTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											downTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_MIDDLE) {
									// 平期耗电量
									List<UpDownDateArea> midTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < midTimeArea.size(); i++) {
										UpDownDateArea midTime = midTimeArea
												.get(i);
										Date startDate = midTime.getStartTime();
										Date endDate = midTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											middleTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								}
							}
						}

						// tlp
						for (UpAndDownElecTabVo v : upAndDownElectabList) {
							for (UpAndDownCompareVo vo : upAndDownCompareList) {
								if (vo.getDate().equals(v.getDate())) {
									vo.setValue2(v.getUpTotalValue());
								}
							}
						}
					}
					// 用于导出Excel：
					request.getSession().setAttribute("upAndDownElectabList",
							upAndDownElectabList);
					// 用于图表：
					this.upAndDownElecList = new ArrayList<UpAndDownElecVo>();
					UpAndDownElecVo vo = new UpAndDownElecVo();
					vo.setName("峰期电量");
					vo.setValue(upTotalValue);
					vo.setPriceName("峰期电费");
					vo.setPriceValue(upTotalValue * upElecPrice);
					upAndDownElecList.add(vo);

					vo = new UpAndDownElecVo();
					vo.setName("平期电量");
					vo.setValue(middleTotalValue);
					vo.setPriceName("平期电费");
					vo.setPriceValue(middleTotalValue * midElecPrice);
					upAndDownElecList.add(vo);

					vo = new UpAndDownElecVo();
					vo.setName("谷期电量");
					vo.setValue(downTotalValue);
					vo.setPriceName("谷期电费");
					vo.setPriceValue(downTotalValue * downElecPrice);
					upAndDownElecList.add(vo);
					// TLP
					// 用于统计值
					this.monObjName = monitorObj.getObj_name();
					this.date = this.startTime;
					this.sumValue = upTotalValue + middleTotalValue
							+ downTotalValue;// 总
					this.upTotalValue = upTotalValue; // 峰
					this.middleTotalValue = middleTotalValue;// 平
					this.downTotalValue = downTotalValue; // 谷

					// System.out.println("[Debug] upTotalValue is :" +
					// upTotalValue + "and percent of " +
					// upTotalValue/sumValue);
					// System.out.println("[Debug] middleTotalValue is:" +
					// middleTotalValue + "and percent of " +
					// middleTotalValue/sumValue);
					// System.out.println("[Debug] downTotalValue is :" +
					// downTotalValue + "and percent of " +
					// downTotalValue/sumValue);
					// System.out.println("[Debug] sumValue is :" + sumValue);
					return SUCCESS;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		return SUCCESS;
	}

	/**
	 * 综合电价分析
	 */

	public String synthesizeEletricityPriceAnlysis() {
		try {
			boolean bPointJsp = false;
			String userNum = request.getParameter("userNum");
			String userName = request.getParameter("userName");
			String userType = request.getParameter("usertype");
			System.out.println("userNum:" + userNum + "\tuserName:" + userName
					+ "\tuserType:" + userType);

			if (userNum != null && !"".equals(userNum)) {
				bPointJsp = true;
				request.getSession().setAttribute(
						StaticVariable.USERNUMSESSION, userNum);
			}
			if (userName != null && !"".equals(userName)) {
				bPointJsp = true;
				request.getSession().setAttribute(
						StaticVariable.USERNAMESESSION, userName);
			}
			if (userType != null && !"".equals(userType)) {
				bPointJsp = true;
				request.getSession().setAttribute(
						StaticVariable.USERTYPESESSION, userType);
			}
			if (bPointJsp)
				return "jsp_page";
			userType = (String) request.getSession().getAttribute(
					StaticVariable.USERTYPESESSION);
			userNum = (String) request.getSession().getAttribute(
					StaticVariable.USERNUMSESSION);
			if (this.getStartTime() == null) {
				return SUCCESS;
			}
			Long monitorObjId = Long.parseLong(userNum);
			MonitoringObj monitorObj = null;

			if (StaticCheckString.checkStr(userType)) {// 如果值等于空、直接返回出去
				request.setAttribute("returnValue", StaticVariable.CUEUSER);
				return SUCCESS;
			} else {
				String queryStartTime = "";
				String queryEndTime = "";
				String timeStr = this.getStartTime().substring(0, 7)
						+ "-01 00:00:00";
				if ("1".equals(userType) || "2".equals(userType)) {
					this.objFunction = "1";
					return SUCCESS;
				} else if ("3".equals(userType) || "4".equals(userType)
						|| "5".equals(userType)) {
					if (timeStr == null || "".equals(timeStr)
							|| "null".equals(timeStr)) {// 进入查询条件选择界面
						return SUCCESS;
					}

					URL url = UpdownEletricityConstrueDaoImpl.class
							.getProtectionDomain().getCodeSource()
							.getLocation();

					String filePath = url.getPath();

					filePath = filePath.substring(0,
							filePath.lastIndexOf("/") + 1);
					filePath = filePath.substring(0, filePath
							.indexOf("WEB-INF"));
					filePath = filePath
							+ "WEB-INF/classes/upAndDownTime.properties";
					File file = new File(filePath);
					FileInputStream fis = new FileInputStream(file);
					// Map接口的子类Properties,键值对对象
					Properties props = new Properties();
					// fis中的键值对信息装载到props对象中
					props.load(fis);
					// 从键值对对象props中通过key找到value
					upTimeStr = props.getProperty("upTime");
					downTimeStr = props.getProperty("downTime");
					midTimeStr = props.getProperty("middleTime");
					monitorObj = ammeterInfoInter.getMonitorObj(monitorObjId);

					if ("1".equals(this.getSelectType())) {// 月度统计
						queryStartTime = timeStr;
						queryEndTime = SharpUtil.getNextMonth(timeStr)
								+ "-01 00:00:00";
					} else if ("2".equals(this.getSelectType())) {// 年度统计
						timeStr = timeStr.substring(0, 4);
						queryStartTime = timeStr + "-01-01 00:00:00";
						int year = Integer.parseInt(timeStr) + 1;
						queryEndTime = year + "-01-01 00:00:00";
					}

					List<Ammeterinfo> reqAmmeterList = ammeterInfoInter
							.getRecursionAmmeterOfMonitoringObj(monitorObjId,
									userType);
					CommonFunctions
							.divideWaterMeterFromAmmeterList(reqAmmeterList);
					List list = energyUserConstrueInter.getEnergyStatistic(
							reqAmmeterList, queryStartTime, queryEndTime); // ???
					DateFormat dateFormat = new SimpleDateFormat(
							"yyyy-MM-dd HH:mm:ss");
					DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH");
					DateFormat df_ = new SimpleDateFormat("yyyy-MM-dd");
					List<DlstatisticVo> statisticVoList = new ArrayList<DlstatisticVo>(); // /???
					Calendar endCalendar = Calendar.getInstance();
					Calendar startCalendar = Calendar.getInstance();

					if (list.size() <= 0) { // 如果一条记录也没查到，应直接返回，下面都不必执行
						return SUCCESS;
					}
					// 得到峰谷电价
					Double priceArray[] = energyUserConstrueInter
							.getDifferentElecPrice();
					upElecPrice = priceArray[0];
					midElecPrice = priceArray[1];
					downElecPrice = priceArray[2];
					System.out.println("upElecPrice:" + upElecPrice
							+ "\tmidElecPrice:" + midElecPrice
							+ "\tdownElecPrice:" + downElecPrice);

					// 初始化操作 upAndDownElectabList
					synElecPriceList = new ArrayList<SynthesizeElecAnlyTabVo>();
					if ("1".equals(this.getSelectType())) { // 月查询
						SynthesizeElecAnlyTabVo tabVo = new SynthesizeElecAnlyTabVo();
						tabVo.setDate(queryStartTime.substring(0, 10));
						tabVo.setMonObjName(monitorObj.getObj_name());
						tabVo.setSumValue(-1d);
						tabVo.setTotalMoney(-1d);
						tabVo.setAveragePrice(-1d);
						synElecPriceList.add(tabVo);

						long milliSecond = 24 * 60 * 60 * 1000;
						int dotCount = StaticCheckString
								.getMaxDayOfMonth(queryStartTime);
						for (int i = 1; i < dotCount; i++) {
							long tempMilliSecond = df_.parse(tabVo.getDate())
									.getTime()
									+ milliSecond;
							tabVo = new SynthesizeElecAnlyTabVo();
							tabVo.setDate(df_.format(tempMilliSecond));
							tabVo.setMonObjName(monitorObj.getObj_name());
							tabVo.setSumValue(-1d);
							tabVo.setTotalMoney(-1d);
							tabVo.setAveragePrice(-1d);
							synElecPriceList.add(tabVo);
						}
					} else { // 年查询
						String month = "";
						SynthesizeElecAnlyTabVo tabVo = null;
						for (int i = 1; i <= 12; i++) {
							tabVo = new SynthesizeElecAnlyTabVo();
							if (i < 10)
								month = "0" + i;
							else
								month = String.valueOf(i);
							tabVo.setDate(queryStartTime.substring(0, 4) + "-"
									+ month);
							tabVo.setMonObjName(monitorObj.getObj_name());
							tabVo.setSumValue(-1d);
							tabVo.setTotalMoney(-1d);
							tabVo.setAveragePrice(-1d);
							synElecPriceList.add(tabVo);
						}
					}

					double totalValue = 0; // ????
					for (int i = 0; i < list.size(); i++) {
						Object[] obj = (Object[]) list.get(i);
						if (obj[1] != null) {
							double reapp = Double
									.parseDouble(obj[1].toString());

							if (reapp > 0.00d) {
								DlstatisticVo dv = new DlstatisticVo();
								dv.setStarttime(dateFormat.format(df
										.parse(obj[0].toString())));
								dv.setPp(reapp + "");
								statisticVoList.add(dv);
								totalValue += reapp;
							}
						}
					}

					// 峰、平、谷
					Map<Integer, List<UpDownDateArea>> timeAreaMap = energyUserConstrueInter
							.getElectricUpDownDateArea();
					Set<Integer> keySet = timeAreaMap.keySet();
					Calendar voStartCalendar = Calendar.getInstance();

					// ------------------------------
					// 每天的电量(解决)
					int end = 7; // 年
					if ("1".equals(this.getSelectType())) {
						end = 10; // 月
					}
					for (SynthesizeElecAnlyTabVo tabVo : synElecPriceList) {
						double dayTotalValue = 0;
						for (int i = 0; i < list.size(); i++) {
							Object[] obj = (Object[]) list.get(i);
							if (obj[1] != null) {
								double reapp = Double.parseDouble(obj[1]
										.toString());
								String date2 = dateFormat.format(
										df.parse(obj[0].toString())).substring(
										0, end);
								if (tabVo.getDate().equals(date2))
									dayTotalValue += reapp;
							}

						}
						if (dayTotalValue != 0.0)
							tabVo.setSumValue(dayTotalValue);
					}
					for (SynthesizeElecAnlyTabVo tabVo : synElecPriceList) {
						double dayUpTotalValue = 0; // 每天的峰期耗电量
						double dayDownTotalValue = 0; // 每天的谷期耗电量
						double dayMiddleTotalValue = 0; // 每天 的平期耗电量
						double daySumValue = 0; // 每天的总耗电量
						double dayTotalMoney = 0; // 每天的总电费
						double dayAveragePrice = 0; // 每天的平均电价

						for (DlstatisticVo vo : statisticVoList) {
							String date2 = dateFormat.format(
									df.parse(vo.getStarttime())).substring(0,
									end);
							if (tabVo.getDate().equals(date2)) {
								String voStartTimeStr = vo.getStarttime();
								Date voStartTime = dateFormat
										.parse(voStartTimeStr);
								voStartCalendar.setTime(voStartTime);
								int voHourOfDay = voStartCalendar
										.get(Calendar.HOUR_OF_DAY);
								for (Integer key : keySet) {
									if (key.intValue() == StaticVariables.ELECTRICDATEAREA_UP) {
										// 峰期耗电量
										List<UpDownDateArea> upTimeArea = timeAreaMap
												.get(key);
										for (int i = 0; i < upTimeArea.size(); i++) {
											UpDownDateArea upTime = upTimeArea
													.get(i);
											Date startDate = upTime
													.getStartTime();
											Date endDate = upTime.getEndTime();
											startCalendar.setTime(startDate);
											int startHour = startCalendar
													.get(Calendar.HOUR_OF_DAY);
											endCalendar.setTime(endDate);
											int endHour = endCalendar
													.get(Calendar.HOUR_OF_DAY);
											if (voHourOfDay >= startHour
													&& voHourOfDay <= endHour) {
												dayUpTotalValue += Double
														.parseDouble(vo.getPp());
												break;
											}
										}
									} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_DOWN) {
										// 谷期耗电量
										List<UpDownDateArea> downTimeArea = timeAreaMap
												.get(key);
										for (int i = 0; i < downTimeArea.size(); i++) {
											UpDownDateArea downTime = downTimeArea
													.get(i);
											Date startDate = downTime
													.getStartTime();
											Date endDate = downTime
													.getEndTime();
											startCalendar.setTime(startDate);
											int startHour = startCalendar
													.get(Calendar.HOUR_OF_DAY);
											endCalendar.setTime(endDate);
											int endHour = endCalendar
													.get(Calendar.HOUR_OF_DAY);
											if (voHourOfDay >= startHour
													&& voHourOfDay <= endHour) {
												dayDownTotalValue += Double
														.parseDouble(vo.getPp());
												break;
											}
										}
									} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_MIDDLE) {
										// 平期耗电量
										List<UpDownDateArea> midTimeArea = timeAreaMap
												.get(key);
										for (int i = 0; i < midTimeArea.size(); i++) {
											UpDownDateArea midTime = midTimeArea
													.get(i);
											Date startDate = midTime
													.getStartTime();
											Date endDate = midTime.getEndTime();
											startCalendar.setTime(startDate);
											int startHour = startCalendar
													.get(Calendar.HOUR_OF_DAY);
											endCalendar.setTime(endDate);
											int endHour = endCalendar
													.get(Calendar.HOUR_OF_DAY);
											if (voHourOfDay >= startHour
													&& voHourOfDay <= endHour) {
												dayMiddleTotalValue += Double
														.parseDouble(vo.getPp());
												break;
											}
										}
									}
								}
							}
						}

						daySumValue = dayUpTotalValue + dayDownTotalValue
								+ dayMiddleTotalValue;

						dayTotalMoney = dayUpTotalValue * upElecPrice
								+ dayMiddleTotalValue * midElecPrice
								+ dayDownTotalValue * downElecPrice;

						if (daySumValue != 0.0) {
							tabVo.setSumValue(daySumValue);
							tabVo.setTotalMoney(dayTotalMoney);
							dayAveragePrice = dayTotalMoney / daySumValue;
							tabVo.setAveragePrice(dayAveragePrice);
						}

						System.out.println("date :" + tabVo.getDate()
								+ "; object :" + tabVo.getMonObjName()
								+ "; sumValue :" + tabVo.getSumValue()
								+ "; totalmoney :" + tabVo.getTotalMoney()
								+ "; averagePrice :" + tabVo.getAveragePrice());
					}

					
					System.out.println("*&&&&&&&&&&&&" + synElecPriceList.size());
					double upTotalValue = 0;
					double downTotalValue = 0;
					double middleTotalValue = 0;
					for (DlstatisticVo vo : statisticVoList) {
						String voStartTimeStr = vo.getStarttime();
						Date voStartTime = dateFormat.parse(voStartTimeStr);
						voStartCalendar.setTime(voStartTime);
						int voHourOfDay = voStartCalendar
								.get(Calendar.HOUR_OF_DAY);
						if (selectType.equals("1") // 月份的情况；
								&& voStartTime.getMonth() == (dateFormat
										.parse(timeStr).getMonth())) {
							for (Integer key : keySet) {
								if (key.intValue() == StaticVariables.ELECTRICDATEAREA_UP) {
									// 峰期耗电量
									List<UpDownDateArea> upTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < upTimeArea.size(); i++) {
										UpDownDateArea upTime = upTimeArea
												.get(i);
										Date startDate = upTime.getStartTime();
										Date endDate = upTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											upTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_DOWN) {
									// 谷期耗电量
									List<UpDownDateArea> downTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < downTimeArea.size(); i++) {
										UpDownDateArea downTime = downTimeArea
												.get(i);
										Date startDate = downTime
												.getStartTime();
										Date endDate = downTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											downTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_MIDDLE) {
									// 平期耗电量
									List<UpDownDateArea> midTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < midTimeArea.size(); i++) {
										UpDownDateArea midTime = midTimeArea
												.get(i);
										Date startDate = midTime.getStartTime();
										Date endDate = midTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											middleTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								}
							}

						} else if (selectType.equals("2")) { // 年份的情况；
							for (Integer key : keySet) {
								if (key.intValue() == StaticVariables.ELECTRICDATEAREA_UP) {
									// 峰期耗电量
									List<UpDownDateArea> upTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < upTimeArea.size(); i++) {
										UpDownDateArea upTime = upTimeArea
												.get(i);
										Date startDate = upTime.getStartTime();
										Date endDate = upTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											upTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_DOWN) {
									// 谷期耗电量
									List<UpDownDateArea> downTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < downTimeArea.size(); i++) {
										UpDownDateArea downTime = downTimeArea
												.get(i);
										Date startDate = downTime
												.getStartTime();
										Date endDate = downTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											downTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								} else if (key.intValue() == StaticVariables.ELECTRICDATEAREA_MIDDLE) {
									// 平期耗电量
									List<UpDownDateArea> midTimeArea = timeAreaMap
											.get(key);
									for (int i = 0; i < midTimeArea.size(); i++) {
										UpDownDateArea midTime = midTimeArea
												.get(i);
										Date startDate = midTime.getStartTime();
										Date endDate = midTime.getEndTime();
										startCalendar.setTime(startDate);
										int startHour = startCalendar
												.get(Calendar.HOUR_OF_DAY);
										endCalendar.setTime(endDate);
										int endHour = endCalendar
												.get(Calendar.HOUR_OF_DAY);
										if (voHourOfDay >= startHour
												&& voHourOfDay <= endHour) {
											middleTotalValue += Double
													.parseDouble(vo.getPp());
											break;
										}
									}
								}
							}
						}
					}

					// 用于导出Excel：
					request.getSession().setAttribute("upAndDownElectabList",
							upAndDownElectabList);
					// 用于图表：
					this.upAndDownElecList = new ArrayList<UpAndDownElecVo>();
					UpAndDownElecVo vo = new UpAndDownElecVo();
					vo.setName("峰期电量");
					vo.setValue(upTotalValue);
					vo.setPriceName("峰期电费");
					vo.setPriceValue(upTotalValue * upElecPrice);
					upAndDownElecList.add(vo);

					vo = new UpAndDownElecVo();
					vo.setName("平期电量");
					vo.setValue(middleTotalValue);
					vo.setPriceName("平期电费");
					vo.setPriceValue(middleTotalValue * midElecPrice);
					upAndDownElecList.add(vo);

					vo = new UpAndDownElecVo();
					vo.setName("谷期电量");
					vo.setValue(downTotalValue);
					vo.setPriceName("谷期电费");
					vo.setPriceValue(downTotalValue * downElecPrice);
					upAndDownElecList.add(vo);
					// TLP
					// 用于统计值
					this.monObjName = monitorObj.getObj_name();
					this.date = this.startTime;
					this.sumValue = upTotalValue + middleTotalValue
							+ downTotalValue;// 总
					this.upTotalValue = upTotalValue; // 峰
					this.middleTotalValue = middleTotalValue;// 平
					this.downTotalValue = downTotalValue; // 谷

					return SUCCESS;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		return SUCCESS;

	}

	/**
	 * 峰谷获得对象名字
	 */
	// public String getMonitorObjNameByID(){
	// try{
	// //tlp
	// System.out.println("进入后台...");
	// HttpServletResponse response = ServletActionContext.getResponse();
	// PrintWriter out = response.getWriter();
	// out.println("{monObjName1:'我',monObjName2:'他'}");
	// }catch(Exception ex){
	// ex.printStackTrace();
	// }
	// return null;
	// }

	/**
	 * 得到开始记录
	 */
	@SuppressWarnings("unused")
	private int getFirstIndex() {
		String pageNo = request.getParameter("pageNo");
		int pageNum;
		if (pageNo == null || "".equals(pageNo)) {
			pageNum = 1;
		} else {
			pageNum = Integer.parseInt(pageNo);
		}
		return (pageNum - 1) * StaticVariables.PAGE_SIZE;
	}

	// 统计用水量
	public String queryWatchData() throws Exception {
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss");
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat ymFormat = new SimpleDateFormat("yyyy-MM");
		String st = ymFormat.format(ymFormat.parse(startTime));
		int dayNum = SharpUtil.getDayNum(st);
		String nextMonth = SharpUtil.getNextMonth(st);
		String queryStartTime = st.substring(0, 7) + "-01 00:00:00";
		String queryEndTime = nextMonth + "-01 00:00:00";

		List<Ammeterinfo> ammeterList = getAllWaterAmmeter();
		List<Dldetail> allList = getDldetail(ammeterList, queryStartTime,
				queryEndTime);// 里面的元素用1号排到下个月的1号
		Map<Ammeterinfo, List<Dldetail>> map = new LinkedHashMap<Ammeterinfo, List<Dldetail>>();
		for (Ammeterinfo a : ammeterList) {
			List<Dldetail> dlList = new ArrayList<Dldetail>();
			map.put(a, dlList);
		}
		Set<Ammeterinfo> keySet = map.keySet();
		for (Dldetail d : allList) {
			for (Ammeterinfo a : keySet) {
				if (a.getId().getRtuano().equals(
						d.getTerminalinfo().getRtuano())
						&& a.getId().getAmmeterno().equals(d.getAmmeterno())) {
					map.get(a).add(d);
					break;
				}
			}
		}
		Map<Ammeterinfo, List<WaterDataVo>> reqMap = new LinkedHashMap<Ammeterinfo, List<WaterDataVo>>();
		for (Ammeterinfo a : ammeterList) {
			List<WaterDataVo> wList = new ArrayList<WaterDataVo>();
			reqMap.put(a, wList);
		}
		keySet = map.keySet();
		for (Ammeterinfo a : keySet) {
			List<Dldetail> dList = map.get(a);
			if (dList.size() < 2) {// 至少有两个元素才能计算耗水量
				continue;
			}
			// 下面区分开每天的表码
			List<List<Dldetail>> listArray = new ArrayList<List<Dldetail>>();// listArray的下标对应此月的几号
			for (int i = 0; i < dayNum; i++) {
				List<Dldetail> tempList = new ArrayList<Dldetail>();
				listArray.add(tempList);
			}
			Date tempDt = dList.get(0).getReaDt();
			String dateStr = df.format(tempDt);
			for (int i = 0; i <= dayNum; i++) {// 可以等于，是因为可能存在下个月第一天零点的数据
				tempDt = new Date(tempDt.getTime() + i * (24 * 3600 * 1000L));
				dateStr = df.format(tempDt);
				for (int j = 0; j < dList.size(); j++) {
					String tempDateStr = df.format(dList.get(j).getReaDt());
					if (tempDateStr.equals(dateStr)) {
						listArray.get(i).add(dList.get(j));
					}
				}
			}
			// 下面生成用于页面展示的数据
			for (int i = 0; i < listArray.size() - 1; i++) {
				List<Dldetail> curList = listArray.get(i);
				List<Dldetail> nextList = listArray.get(i + 1);
				if (curList.size() > 1) {
					String curStr = dateFormat
							.format(curList.get(0).getReaDt());
					Double dStart = curList.get(0).getReaPp();
					Double dEnd = null;
					if (nextList.size() > 0) {
						String nextStr = dateFormat.format(nextList.get(0)
								.getReaDt());
						if (nextStr.indexOf("00:00:00") != -1) {// 存在第二天零点的值
							dEnd = nextList.get(0).getReaPp();
						} else {// 不存在第二天零点的值
							dEnd = curList.get(curList.size() - 1).getReaPp();
						}
					} else {
						dEnd = curList.get(curList.size() - 1).getReaPp();
					}
					if (dEnd != null && dEnd > dStart) {
						WaterDataVo vo = new WaterDataVo();
						vo.setStartTime(curStr);
						vo.setUsedValue((dEnd - dStart) + "");
						reqMap.get(a).add(vo);
					}
				} else if (curList.size() == 1 && nextList.size() > 0) {
					String curStr = dateFormat
							.format(curList.get(0).getReaDt());
					Double dStart = curList.get(0).getReaPp();
					Double dEnd = null;
					String nextStr = dateFormat.format(nextList.get(0)
							.getReaDt());
					if (nextStr.indexOf("00:00:00") != -1) {// 存在第二天零点的值,不存在就不计算了
						dEnd = nextList.get(0).getReaPp();
					}
					if (dEnd != null && dEnd > dStart) {
						WaterDataVo vo = new WaterDataVo();
						vo.setStartTime(curStr);
						vo.setUsedValue((dEnd - dStart) + "");
						reqMap.get(a).add(vo);
					}
				}
			}
		}
		return SUCCESS;
	}

	// mixList已按时间排序
	private List<StatisticAmmeterInfoVo> getElectricQuantityFromMixList(
			List<Dldetail> mixList, Ammeterinfo ammeter) throws Exception {
		List<StatisticAmmeterInfoVo> reqList = new ArrayList<StatisticAmmeterInfoVo>();
		List<Dldetail> tempList = new ArrayList<Dldetail>();
		Long rtuano = ammeter.getId().getRtuano();
		Long ammeterno = ammeter.getId().getAmmeterno();
		for (Dldetail d : mixList) {
			if (d.getTerminalinfo().getRtuano().equals(rtuano)
					&& d.getAmmeterno().equals(ammeterno)) {
				tempList.add(d);
			}
		}
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Long multipleRate = ammeter.getCt() * ammeter.getPt();
		int size = tempList.size();
		for (int i = 0; i < size - 1; i++) {
			Dldetail dEndDldetail = tempList.get(i);
			Double dEnd = dEndDldetail.getReaPp();
			Dldetail dStartDldetail = tempList.get(i + 1);
			Double dStart = dStartDldetail.getReaPp();
			if (dEnd != null && dStart != null) {
				if (dEnd > dStart) {
					Double pp = (dEnd - dStart) * multipleRate;
					StatisticAmmeterInfoVo v = new StatisticAmmeterInfoVo();
					v.setRtuano(rtuano + "");
					v.setAmmeterno(ammeterno + "");
					v.setRea_pp_subtract(pp + "");
					v.setStartTime(sdf.format(dStartDldetail.getReaDt()));
					reqList.add(v);
				}
			}
		}
		return reqList;
	}

	/*
	 * 获得同级对象
	 * 
	 * @TLP
	 * 
	 * @2012-03-10
	 */
	public String getSameUnit() throws Exception {
		String usertype = (String) request.getSession().getAttribute(
				StaticVariable.USERTYPESESSION);
		String userNum = (String) request.getSession().getAttribute(
				StaticVariable.USERNUMSESSION);
		// System.out.println("getSameUnit()==>usertype:"+usertype+"\tuserNum:"+userNum);
		List<MonitoringObjVo> sameUnitList = new ArrayList<MonitoringObjVo>();
		List<MonitoringObjVo> levelNodeList = StaticVariable
				.getSpecialLevelTreeNodes(Integer.parseInt(usertype));
		for (MonitoringObjVo v : levelNodeList) {
			if (v.getObj_id().equals(userNum))
				continue;
			sameUnitList.add(v);
		}
		int size = sameUnitList.size();
		jsonString = "[{'abbr':'-1','name':'== 不选 =='}";
		if (size > 0)
			jsonString = jsonString + ",";
		for (int i = 0; i < size; i++) {
			MonitoringObjVo monObjVo = sameUnitList.get(i);
			jsonString += "{'abbr':";
			jsonString += monObjVo.getObj_id();
			jsonString += ",'name':'";
			jsonString += monObjVo.getObj_name();
			jsonString += "'}";
			if (i != size - 1)
				jsonString += ",";
		}
		jsonString += "]";
		return "jsonString";
	}

	public String updownExp() {
		HttpServletResponse response = ServletActionContext.getResponse();
		try {
			response.setContentType("text/html; kcharset=UTF-8");
			response.setContentType("application/vnd.ms-excel");
			InputStream is = generateExcelFile();
			if (is == null) {
				return "jsp_page";
			}
			// 解决中文乱码
			response.setHeader("Content-Disposition", "attachment;filename="
					+ new String(tempFileName.getBytes("GBK"), "ISO-8859-1"));
			BufferedInputStream buff = new BufferedInputStream(is);
			byte[] b = new byte[1024];
			int k = 0;
			// 从response对象中得到输出流,准备下载
			OutputStream myout = response.getOutputStream();
			// 开始循环下载
			while ((k = buff.read(b, 0, 1024)) != -1) {
				myout.write(b, 0, k);
			}
			myout.flush();
			myout.close();
			response.flushBuffer();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return null;
	}

	private InputStream generateExcelFile() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		String tempPathStr = sdf.format(new Date());
		tempPathStr = tempPathStr.replaceAll(" ", "_");
		tempPathStr = tempPathStr.replaceAll(":", "-");
		File file = new File(".\\" + tempPathStr + ".xls");
		try {
			if (!file.exists())
				file.createNewFile();
			tempFileName = file.getName();
			upAndDownElectabList = (List<UpAndDownElecTabVo>) request
					.getSession().getAttribute("upAndDownElectabList");
			// 以下代码实现导出excel表格
			String title_ = "峰谷日耗电量数据表";
			if ("2".equals(this.selectType))
				title_ = "峰谷月耗电量数据表";
			OutputStream os = new FileOutputStream(file);
			WritableWorkbook wbook = Workbook.createWorkbook(os); // 建立excel文件
			WritableSheet wsheet = wbook.createSheet(title_, 0); // 工作表名称
			SheetSettings ss = wsheet.getSettings();
			ss.setDefaultColumnWidth(16);
			WritableFont titleFont = new WritableFont(WritableFont
					.createFont("黑体"), 24, WritableFont.BOLD, false,
					jxl.format.UnderlineStyle.NO_UNDERLINE,
					jxl.format.Colour.BLACK);
			WritableCellFormat titleFormat = new WritableCellFormat(titleFont);
			titleFormat.setAlignment(jxl.format.Alignment.CENTRE);
			// 设置Excel字体
			WritableFont wfont = new WritableFont(WritableFont.ARIAL, 8,
					WritableFont.BOLD, false,
					jxl.format.UnderlineStyle.NO_UNDERLINE,
					jxl.format.Colour.BLACK);
			WritableCellFormat subTitleFormat = new WritableCellFormat(wfont);
			// 左对齐样式：
			WritableCellFormat leftWcf = new WritableCellFormat();
			leftWcf.setAlignment(jxl.format.Alignment.LEFT);
			wsheet.mergeCells(0, 0, 6, 0);
			wsheet.addCell(new Label(0, 0, title_, titleFormat));
			String[] title = { "序号", "监测对象", "日期", "总耗电量(KWh)", "峰期耗电量(KWh)",
					"平期耗电量(KWh)", "谷期耗电量(KWh)" };
			// 设置Excel表头
			for (int i = 0; i < title.length; i++) {
				Label excelTitle = new Label(i, 1, title[i], subTitleFormat);
				wsheet.addCell(excelTitle);
			}
			DecimalFormat decimalFormat = new DecimalFormat();
			decimalFormat.setGroupingUsed(false);
			decimalFormat.setMaximumFractionDigits(2);
			decimalFormat.setMinimumFractionDigits(2);
			int rowNo = 2;
			
			
			for (int i = 0; i < upAndDownElectabList.size(); i++) {
				UpAndDownElecTabVo upAndDownElecTabVo = upAndDownElectabList
						.get(i);
				wsheet.addCell(new Number(0, rowNo, rowNo - 1, leftWcf));
				wsheet.addCell(new Label(1, rowNo, upAndDownElecTabVo
						.getMonObjName()));
				wsheet
						.addCell(new Label(2, rowNo, upAndDownElecTabVo
								.getDate()));
				double sumValue = upAndDownElecTabVo.getSumValue();
				double upValue = upAndDownElecTabVo.getUpTotalValue();
				double middleValue = upAndDownElecTabVo.getMiddleTotalValue();
				double downValue = upAndDownElecTabVo.getDownTotalValue();
				if (sumValue == -1d)
					wsheet.addCell(new Label(3, rowNo, ""));
				else
					wsheet.addCell(new Number(3, rowNo, sumValue));
				if (upValue == -1d)
					wsheet.addCell(new Label(4, rowNo, ""));
				else
					wsheet.addCell(new Number(4, rowNo, upValue));
				if (middleValue == -1d)
					wsheet.addCell(new Label(5, rowNo, ""));
				else
					wsheet.addCell(new Number(5, rowNo, middleValue));
				if (downValue == -1d)
					wsheet.addCell(new Label(6, rowNo, ""));
				else
					wsheet.addCell(new Number(6, rowNo, downValue));
				rowNo++;
			}
			wbook.write(); // 写入文件
			os.flush();
			wbook.close();
			os.close();
			return new FileInputStream(file);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public String getUserPosition() {
		return userPosition;
	}

	public void setUserPosition(String userPosition) {
		this.userPosition = userPosition;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	public String getSelectType() {
		return selectType;
	}

	public void setSelectType(String selectType) {
		this.selectType = selectType;
	}

	public void setAmmeterInfoInter(AmmeterServiceInter ammeterInfoInter) {
		this.ammeterInfoInter = ammeterInfoInter;
	}

	public void setEnergyUserConstrueInter(
			EnergyUserConstrueInter energyUserConstrueInter) {
		this.energyUserConstrueInter = energyUserConstrueInter;
	}

	public List<UpAndDownElecVo> getUpAndDownElecList() {
		return upAndDownElecList;
	}

	public void setUpAndDownElecList(List<UpAndDownElecVo> upAndDownElecList) {
		this.upAndDownElecList = upAndDownElecList;
	}

	public List<SynthesizeElecAnlyTabVo> getSynElecPriceList() {
		return synElecPriceList;
	}

	public void setSynElecPriceList(
			List<SynthesizeElecAnlyTabVo> synElecPriceList) {
		this.synElecPriceList = synElecPriceList;
	}

	public String getSameUnitID() {
		return sameUnitID;
	}

	public void setSameUnitID(String sameUnitID) {
		this.sameUnitID = sameUnitID;
	}

	public List<Ammeterinfo> getAllWaterAmmeter() {
		return null;
	}

	public List<Dldetail> getDldetail(List<Ammeterinfo> ammeterList,
			String startTime, String endTime) {
		return null;
	}

	public List<ElecConstrueVo> getElecConstrueVoList() {
		return elecConstrueVoList;
	}

	public void setElecConstrueVoList(List<ElecConstrueVo> elecConstrueVoList) {
		this.elecConstrueVoList = elecConstrueVoList;
	}

	public List<EnergyCraftCompareVo> getEnergyCraftCompareVoList() {
		return energyCraftCompareVoList;
	}

	public void setEnergyCraftCompareVoList(
			List<EnergyCraftCompareVo> energyCraftCompareVoList) {
		this.energyCraftCompareVoList = energyCraftCompareVoList;
	}

	public String getJsonString() {
		return jsonString;
	}

	public void setJsonString(String jsonString) {
		this.jsonString = jsonString;
	}

	public Double getLightElec() {
		return lightElec;
	}

	public void setLightElec(Double lightElec) {
		this.lightElec = lightElec;
	}

	public Double getAirElec() {
		return airElec;
	}

	public void setAirElec(Double airElec) {
		this.airElec = airElec;
	}

	public Double getDriverElec() {
		return driverElec;
	}

	public void setDriverElec(Double driverElec) {
		this.driverElec = driverElec;
	}

	public Double getOtherElec() {
		return otherElec;
	}

	public void setOtherElec(Double otherElec) {
		this.otherElec = otherElec;
	}

	public List<UpAndDownElecVo> getSortElecList() {
		return sortElecList;
	}

	public void setSortElecList(List<UpAndDownElecVo> sortElecList) {
		this.sortElecList = sortElecList;
	}

	public Double getElec() {
		return elec;
	}

	public void setElec(Double elec) {
		this.elec = elec;
	}

	public Double getWater() {
		return water;
	}

	public void setWater(Double water) {
		this.water = water;
	}

	public Double getGas() {
		return gas;
	}

	public void setGas(Double gas) {
		this.gas = gas;
	}

	public Double getHeat() {
		return heat;
	}

	public void setHeat(Double heat) {
		this.heat = heat;
	}

	public Double getCol() {
		return col;
	}

	public void setCol(Double col) {
		this.col = col;
	}

	public Double getOther() {
		return other;
	}

	public void setOther(Double other) {
		this.other = other;
	}

	public String getObjFunction() {
		return objFunction;
	}

	public void setObjFunction(String objFunction) {
		this.objFunction = objFunction;
	}

	public List<UpAndDownElecTabVo> getUpAndDownElectabList() {
		return upAndDownElectabList;
	}

	public void setUpAndDownElectabList(
			List<UpAndDownElecTabVo> upAndDownElectabList) {
		this.upAndDownElectabList = upAndDownElectabList;
	}

	public String getMonObjName() {
		return monObjName;
	}

	public void setMonObjName(String monObjName) {
		this.monObjName = monObjName;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public double getSumValue() {
		return sumValue;
	}

	public void setSumValue(double sumValue) {
		this.sumValue = sumValue;
	}

	public double getUpTotalValue() {
		return upTotalValue;
	}

	public void setUpTotalValue(double upTotalValue) {
		this.upTotalValue = upTotalValue;
	}

	public double getMiddleTotalValue() {
		return middleTotalValue;
	}

	public void setMiddleTotalValue(double middleTotalValue) {
		this.middleTotalValue = middleTotalValue;
	}

	public double getDownTotalValue() {
		return downTotalValue;
	}

	public void setDownTotalValue(double downTotalValue) {
		this.downTotalValue = downTotalValue;
	}

	public List<UpAndDownCompareVo> getUpAndDownCompareList() {
		return upAndDownCompareList;
	}

	public void setUpAndDownCompareList(
			List<UpAndDownCompareVo> upAndDownCompareList) {
		this.upAndDownCompareList = upAndDownCompareList;
	}

	public String getMonObjName1() {
		return monObjName1;
	}

	public void setMonObjName1(String monObjName1) {
		this.monObjName1 = monObjName1;
	}

	public String getMonObjName2() {
		return monObjName2;
	}

	public void setMonObjName2(String monObjName2) {
		this.monObjName2 = monObjName2;
	}

	public double getUpElecPrice() {
		return upElecPrice;
	}

	public void setUpElecPrice(double upElecPrice) {
		this.upElecPrice = upElecPrice;
	}

	public double getMidElecPrice() {
		return midElecPrice;
	}

	public void setMidElecPrice(double midElecPrice) {
		this.midElecPrice = midElecPrice;
	}

	public double getDownElecPrice() {
		return downElecPrice;
	}

	public void setDownElecPrice(double downElecPrice) {
		this.downElecPrice = downElecPrice;
	}

	public String getUpTimeStr() {
		return upTimeStr;
	}

	public void setUpTimeStr(String upTimeStr) {
		this.upTimeStr = upTimeStr;
	}

	public String getDownTimeStr() {
		return downTimeStr;
	}

	public void setDownTimeStr(String downTimeStr) {
		this.downTimeStr = downTimeStr;
	}

	public String getMidTimeStr() {
		return midTimeStr;
	}

	public void setMidTimeStr(String midTimeStr) {
		this.midTimeStr = midTimeStr;
	}
}
